diff options
author | László Németh <nemeth@numbertext.org> | 2022-05-26 09:09:38 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-05-26 16:37:02 +0200 |
commit | 8c018910ae4d8701b1ce2a95727b9baed4016da3 (patch) | |
tree | e0155b8a29d3b60cd78dd98c8bcf57df612d477a /sw/qa | |
parent | ec694a32ea6c9f0287e8c12f4de62047abfcde72 (diff) |
tdf#149248 sw offapi xmloff: add option to not hyphenate last word
Add option to disable automatic hyphenation of the last word of
paragraphs for better typography.
Note: the same option used e.g. in Adobe InDesign, and a
similar one in CSS Text Module Level 4 (hyphenate-limit-last).
* Add checkbox to Text Flow in paragraph dialog
* Store property in paragraph model (com::sun::star::style::ParagraphProperties::ParaHyphenationNoLastWord)
* Add ODF import/export
* Add ODF unit test
* Add layout test
Follow-up to commit 72bd0df107ee47c4d54fa88b4960d32ea03e9f69
"tdf#121658 Add option to not hyphenate words in CAPS".
Change-Id: Ida29c65b5a7cbfd7c399c342781531a6fb86f639
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134985
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/layout/data/tdf149248.odt | bin | 0 -> 20313 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 15 | ||||
-rw-r--r-- | sw/qa/extras/odfexport/data/tdf149248.odt | bin | 0 -> 20313 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 7 | ||||
-rw-r--r-- | sw/qa/uitest/styleInspector/styleInspector.py | 20 | ||||
-rw-r--r-- | sw/qa/uitest/styleInspector/tdf137513.py | 2 |
6 files changed, 33 insertions, 11 deletions
diff --git a/sw/qa/extras/layout/data/tdf149248.odt b/sw/qa/extras/layout/data/tdf149248.odt Binary files differnew file mode 100644 index 000000000000..18685bd0a585 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf149248.odt diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index cca5636d933c..93dbd19184a4 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -4161,6 +4161,21 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf121658) assertXPath(pXmlDoc, "//Special[@nType='PortionType::Hyphen']", 2); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf149248) +{ + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString()))) + return; + + createSwDoc(DATA_DIRECTORY, "tdf149248.odt"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // Only 1 hyphenated word should appear in the document (last word of the second + // paragraph). Last word should not be hyphenated for the fourth paragraph + // (the same paragraph, but with forbidden hyphenation of the last word). + assertXPath(pXmlDoc, "//Special[@nType='PortionType::Hyphen']", 1); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testWriterImageNoCapture) { createSwDoc(DATA_DIRECTORY, "writer-image-no-capture.docx"); diff --git a/sw/qa/extras/odfexport/data/tdf149248.odt b/sw/qa/extras/odfexport/data/tdf149248.odt Binary files differnew file mode 100644 index 000000000000..18685bd0a585 --- /dev/null +++ b/sw/qa/extras/odfexport/data/tdf149248.odt diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index bd11c7406a68..743ee2b475af 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -3038,6 +3038,13 @@ DECLARE_ODFEXPORT_TEST(tdf121658, "tdf121658.odt") CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle1, "ParaHyphenationNoCaps")); } +DECLARE_ODFEXPORT_TEST(tdf149248, "tdf149248.odt") +{ + CPPUNIT_ASSERT_EQUAL(1, getPages()); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getParagraph(2), "ParaHyphenationNoLastWord")); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getParagraph(4), "ParaHyphenationNoLastWord")); +} + DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.odt") { CPPUNIT_ASSERT_EQUAL(1, getPages()); diff --git a/sw/qa/uitest/styleInspector/styleInspector.py b/sw/qa/uitest/styleInspector/styleInspector.py index 14b4590582cf..49d02fc01c9b 100644 --- a/sw/qa/uitest/styleInspector/styleInspector.py +++ b/sw/qa/uitest/styleInspector/styleInspector.py @@ -26,7 +26,7 @@ class styleNavigator(UITestCase): # The cursor is on text without formatting and default style self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) self.assertEqual(0, len(xListBox.getChild('1').getChildren())) self.assertEqual(0, len(xListBox.getChild('2').getChildren())) self.assertEqual(0, len(xListBox.getChild('3').getChildren())) @@ -36,7 +36,7 @@ class styleNavigator(UITestCase): # The cursor is on text with direct formatting self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) self.assertEqual(0, len(xListBox.getChild('1').getChildren())) self.assertEqual(0, len(xListBox.getChild('2').getChildren())) @@ -54,7 +54,7 @@ class styleNavigator(UITestCase): # The cursor is on text with paragraph direct formatting self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) xParDirFormatting = xListBox.getChild('1') self.assertEqual(7, len(xParDirFormatting.getChildren())) @@ -75,7 +75,7 @@ class styleNavigator(UITestCase): xParStyle = xListBox.getChild('0') self.assertEqual(3, len(xParStyle.getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xParStyle.getChild('0'))['Text']) - self.assertEqual(137, len(xParStyle.getChild('0').getChildren())) + self.assertEqual(138, len(xParStyle.getChild('0').getChildren())) self.assertEqual("Heading\t", get_state_as_dict(xParStyle.getChild('1'))['Text']) self.assertEqual(28, len(xParStyle.getChild('1').getChildren())) @@ -109,7 +109,7 @@ class styleNavigator(UITestCase): xParStyle = xListBox.getChild('0') self.assertEqual(3, len(xParStyle.getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xParStyle.getChild('0'))['Text']) - self.assertEqual(137, len(xParStyle.getChild('0').getChildren())) + self.assertEqual(138, len(xParStyle.getChild('0').getChildren())) self.assertEqual("Text Body\t", get_state_as_dict(xParStyle.getChild('1'))['Text']) self.assertEqual(6, len(xParStyle.getChild('1').getChildren())) @@ -144,7 +144,7 @@ class styleNavigator(UITestCase): # The cursor is on text without metadata self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) self.assertEqual(0, len(xListBox.getChild('1').getChildren())) self.assertEqual(0, len(xListBox.getChild('2').getChildren())) self.assertEqual(0, len(xListBox.getChild('3').getChildren())) @@ -154,7 +154,7 @@ class styleNavigator(UITestCase): # The cursor is on text with paragraph metadata showed under direct paragraph formatting self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) xParDirFormatting = xListBox.getChild('1') self.assertEqual(1, len(xParDirFormatting.getChildren())) @@ -207,7 +207,7 @@ class styleNavigator(UITestCase): # The cursor is on text without metadata self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) self.assertEqual(0, len(xListBox.getChild('1').getChildren())) self.assertEqual(0, len(xListBox.getChild('2').getChildren())) self.assertEqual(0, len(xListBox.getChild('3').getChildren())) @@ -217,7 +217,7 @@ class styleNavigator(UITestCase): # The cursor is on text with paragraph metadata showed under direct paragraph formatting self.assertEqual(1, len(xListBox.getChild('1').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('1').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('1').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('1').getChild('0').getChildren())) # Outer bookmark xBookmarkFormatting = xListBox.getChild('0') @@ -264,7 +264,7 @@ class styleNavigator(UITestCase): # The cursor is on text without metadata self.assertEqual(1, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) self.assertEqual(0, len(xListBox.getChild('1').getChildren())) self.assertEqual(0, len(xListBox.getChild('2').getChildren())) diff --git a/sw/qa/uitest/styleInspector/tdf137513.py b/sw/qa/uitest/styleInspector/tdf137513.py index 63d208dc2d86..f04f6106cf7c 100644 --- a/sw/qa/uitest/styleInspector/tdf137513.py +++ b/sw/qa/uitest/styleInspector/tdf137513.py @@ -35,7 +35,7 @@ class tdf137513(UITestCase): self.assertEqual(2, len(xListBox.getChild('0').getChildren())) self.assertEqual("Default Paragraph Style\t", get_state_as_dict(xListBox.getChild('0').getChild('0'))['Text']) self.assertEqual("Table Contents\t", get_state_as_dict(xListBox.getChild('0').getChild('1'))['Text']) - self.assertEqual(137, len(xListBox.getChild('0').getChild('0').getChildren())) + self.assertEqual(138, len(xListBox.getChild('0').getChild('0').getChildren())) xTableContent = xListBox.getChild('0').getChild('1') self.assertEqual(5, len(xTableContent.getChildren())) |