From b5b57c677fd7fe9b2594e428c556862df88fca9d Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 14 Oct 2016 23:31:16 +0200 Subject: tdf#64038 ODF import: fix handling of space following MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whitespace collapse algorithm given in ODF 1.2 part 1, "6.1.2 White Space Characters", was not implemented as well as it could be. Although the problematic case is arguably invalid, because "6.1.3 " says: This element shall be used to represent the second and all following “ “ (U+0020, SPACE) characters in a sequence of “ “ (U+0020, SPACE) characters. Hence it is probably irrelevant in practice that a space following was ignored, because a conforming document cannot have such content. Change-Id: Ic30347fff27176c511ea317d46a1011b410e57d5 --- sw/qa/extras/odfimport/data/space.odt | Bin 0 -> 3839 bytes sw/qa/extras/odfimport/odfimport.cxx | 79 ++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 sw/qa/extras/odfimport/data/space.odt (limited to 'sw/qa') diff --git a/sw/qa/extras/odfimport/data/space.odt b/sw/qa/extras/odfimport/data/space.odt new file mode 100644 index 000000000000..66b5109efca0 Binary files /dev/null and b/sw/qa/extras/odfimport/data/space.odt differ diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index e8bc1cf41f51..90f1da1f96f2 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -249,6 +249,85 @@ DECLARE_ODFIMPORT_TEST(testPageStyleLayoutDefault, "hello.odt") CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty(xPropertySet, "PageStyleLayout")); } +DECLARE_ODFIMPORT_TEST(testTdf64038, "space.odt") +{ + // no space + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(4), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(4), 2)->getString()); + // one space + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(6), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(6), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(7), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(7), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(7), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(8), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" b"), getRun(getParagraph(8), 2)->getString()); + // two spaces + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(10), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(10), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(10), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(11), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(11), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(12), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(12), 2)->getString()); + // three spaces + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(14), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(14), 2)->getString()); + // no space + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(17), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(17), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(17), 3)->getString()); + // one space + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(19), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(19), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(19), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(20), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(20), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(20), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(21), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(21), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(21), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(22), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(22), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" b"), getRun(getParagraph(22), 3)->getString()); + // two spaces + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(24), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(24), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(24), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(25), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(25), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(25), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(26), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(26), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" b"), getRun(getParagraph(26), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(27), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(27), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(27), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(28), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(28), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" b"), getRun(getParagraph(28), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(29), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(29), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(29), 3)->getString()); + // three spaces + CPPUNIT_ASSERT_EQUAL(OUString("a"), getRun(getParagraph(31), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(31), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(31), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(32), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(32), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(32), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(33), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(33), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" b"), getRun(getParagraph(33), 3)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(34), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(34), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(34), 3)->getString()); + // four spaces + CPPUNIT_ASSERT_EQUAL(OUString("a "), getRun(getParagraph(36), 1)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), getRun(getParagraph(36), 2)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("b"), getRun(getParagraph(36), 3)->getString()); +} + DECLARE_ODFIMPORT_TEST(testTdf74524, "tdf74524.odt") { uno::Reference xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); -- cgit