diff options
author | Jakub Trzebiatowski <ubap.dev@gmail.com> | 2016-06-22 22:40:20 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-06-24 08:51:43 +0000 |
commit | d945e97d8f85465f04f59fd197ded2edb56caac3 (patch) | |
tree | 2fa66af81ae05f73d91ca60e66d5eb3d01195916 /sw/qa/python | |
parent | c144288abe73262178a8fd94baef895e1744c304 (diff) |
GSoC Table Style Family: insertByName, replaceByName, removeByName
- also implements SwXTextTableStyle::replaceByName
- some refactorization
+ use std::unique_ptr
- fixes some bugs:
+ posible nullptr dereference in tblafmt.cxx
+ SwXTextTableStyle::getName() returned translated name
+ remvoed unnecesary SetXObject in Cell Style Family replacebyName
- tests
Change-Id: Idd25d54695ab5a4bdd4daf7ebf37b05fbc2366e7
Reviewed-on: https://gerrit.libreoffice.org/26578
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/qa/python')
-rw-r--r-- | sw/qa/python/check_styles.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py index 144082a1cdaa..372455ed70ea 100644 --- a/sw/qa/python/check_styles.py +++ b/sw/qa/python/check_styles.py @@ -171,6 +171,7 @@ class CheckStyle(unittest.TestCase): vEmptyDocStyles = ['Default Style'] self.__test_StyleFamily(xTableStyles, vEmptyDocStyles, "SwXTextTableStyle") self.__test_StyleFamilyIndex(xTableStyles, vEmptyDocStyles, "SwXTextTableStyle") + self.__test_StyleFamilyInsert(xDoc, xTableStyles, vEmptyDocStyles, "com.sun.star.style.TableStyle", "com.sun.star.style.CharacterStyle") for sStyleName in vEmptyDocStyles: self.assertIsNotNone(xTableStyles.getByName(sStyleName)) #check SwXTextCellStyles @@ -184,7 +185,6 @@ class CheckStyle(unittest.TestCase): xDoc.dispose() def test_tableStyleIsInUse(self): - # extend when TableStyle insertByName comes xDoc = CheckStyle._uno.openEmptyWriterDoc() xBodyText = xDoc.getText() xCursor = xBodyText.createTextCursor() @@ -201,6 +201,14 @@ class CheckStyle(unittest.TestCase): xTable.setPropertyValue("TableTemplateName", "") self.assertFalse(xDefaultTableStyle.isInUse()) self.assertFalse(xDefaultCellStyle.isInUse()) + xTableStyle = xDoc.createInstance("com.sun.star.style.TableStyle") + self.assertFalse(xTableStyle.isInUse()) + xDoc.StyleFamilies.getByName("TableStyles").insertByName("Test Table Style", xTableStyle) + self.assertFalse(xTableStyle.isInUse()) + xTable.setPropertyValue("TableTemplateName", "Test Table Style") + self.assertTrue(xTableStyle.isInUse()) + xTable.setPropertyValue("TableTemplateName", "") + self.assertFalse(xTableStyle.isInUse()) xDoc.dispose() def test_CellFamily(self): @@ -210,7 +218,25 @@ class CheckStyle(unittest.TestCase): self.__test_StyleFamily(xCellStyles, vEmptyDocStyles, "SwXTextCellStyle") self.__test_StyleFamilyIndex(xCellStyles, vEmptyDocStyles, "SwXTextCellStyle") self.__test_StyleFamilyInsert(xDoc, xCellStyles, vEmptyDocStyles, "com.sun.star.style.CellStyle", "com.sun.star.style.CharacterStyle") - #add more tests when TableStyles will support insertByName + xTableStyle = xDoc.createInstance("com.sun.star.style.TableStyle") + xCellStyle = xTableStyle.getByName("first-row") + xDoc.StyleFamilies.getByName("TableStyles").insertByName("Test Table Style", xTableStyle) + self.assertEqual(xTableStyle.getByName("first-row"), xCellStyle) + self.assertEqual(xTableStyle.getByName("first-row"), xDoc.StyleFamilies.getByName("TableStyles").getByName("Test Table Style").getByName("first-row")) + #replaceByName + with self.assertRaises(NoSuchElementException): + xTableStyle.replaceByName("foobarbaz", xCellStyle) + xCellStyle = xDoc.createInstance("com.sun.star.style.CellStyle") + with self.assertRaises(IllegalArgumentException): #replace with not inserted cell style + xTableStyle.replaceByName("first-row", xCellStyle) + xTableStyle2 = xDoc.createInstance("com.sun.star.style.TableStyle") + with self.assertRaises(IllegalArgumentException): #replace with other family style + xTableStyle.replaceByName("first-row", xTableStyle2) + with self.assertRaises(IllegalArgumentException): #replace with already assigned cell style + xTableStyle.replaceByName("first-row", xTableStyle2.getByName("first-row")) + xDoc.StyleFamilies.getByName("CellStyles").insertByName("Test Cell Style", xCellStyle) + xTableStyle.replaceByName("first-row", xCellStyle) + self.assertEqual(xTableStyle.getByName("first-row"), xCellStyle) xDoc.dispose() if __name__ == '__main__': |