diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-10-14 23:31:16 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-10-14 23:49:29 +0200 |
commit | b5b57c677fd7fe9b2594e428c556862df88fca9d (patch) | |
tree | e4d41ae84c553f8ddc4e20a7b329fb84d7053b29 /sw/qa | |
parent | df84fdc645462e070b0227909f95716592885bde (diff) |
tdf#64038 ODF import: fix handling of space following <text:s>
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
<text:s>" 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 <text:s>
was ignored, because a conforming document cannot have such content.
Change-Id: Ic30347fff27176c511ea317d46a1011b410e57d5
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/odfimport/data/space.odt | bin | 0 -> 3839 bytes | |||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 79 |
2 files changed, 79 insertions, 0 deletions
diff --git a/sw/qa/extras/odfimport/data/space.odt b/sw/qa/extras/odfimport/data/space.odt Binary files differnew file mode 100644 index 000000000000..66b5109efca0 --- /dev/null +++ b/sw/qa/extras/odfimport/data/space.odt 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<style::PageStyleLayout>(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<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); |