summaryrefslogtreecommitdiff
path: root/sw/qa/extras/odfexport/odfexport.cxx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2020-02-03 00:28:04 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2020-02-05 10:11:17 +0100
commit7d08664be4d9a949718ce66e3bc974105a10284c (patch)
tree53f7ef660ebd436568e28a957166bb373c6848d6 /sw/qa/extras/odfexport/odfexport.cxx
parent9811796aba7360fc5b7230a8b314a56fbf6ab27a (diff)
tdf#129568 Rename the default table style
As it turns out, UI names of table styles are leaking into documents, and changing those names actually breaks the import of documents from previous versions. The problem is that a table style itself is saved using its programmatic name, but is referenced by tables using its UI name. So after changing the UI name, these no longer map. It's still possible to manually reapply the style, but if not doing this and just saving, the style and its child cell styles will be silently lost. Moreover, if the given document is of fodt type, it's not even possible to save it (even not as "save as" to odt). Obviously, the issue isn't just with renaming. The same happens also with documents created with a different UI language (even English). Fortunately, up to now English UI names were identical to the programmatic ones. So the first thing we can do is to accept both kinds of names for table:template-name. This way, we solved the problem for documents created in an English UI, and in addition made them work in non-English UI (unlike before). As for export, we want to always writes programmatic names, so newly edited documents will continue to work regardless of future UI changes or UI language switching (and also stay compatible with older versions). For the fodt export failure, changed the order of things in SwXTextTableStyle::replaceByName, as setting a new box breaks SwXTextCellStyle::getName in this specific case. Also changed cell styles to be named using the parent style's programmatic name, so new documents won't have this problem when opened in older versions. This also fixed part of the PythonTest_sw_python failure. The remaining PythonTest_sw_python failure was about the "TableTemplateName" UNO API property of a table, which didn't work with programmatic names. That's a real bug by itself, and was fixed. Also an explicit test was added, to make sure the API always returns the programmatic name. Finally, an odf export test was added. It tests files with both old-style UI names, and new-style programmatic names. Styles should be correctly imported, used by the table, and survive export. Change-Id: I45dfda193813fea184dc42e5e75544ebc05d4a92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87826 Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com> Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sw/qa/extras/odfexport/odfexport.cxx')
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 7c21a6ca6d35..a7af9a7f3553 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2007,6 +2007,22 @@ DECLARE_ODFEXPORT_TEST(testTableStyles5, "table_styles_5.odt")
}
+DECLARE_ODFEXPORT_TEST(testTdf129568, "tdf129568.fodt")
+{
+ // Test that export doesn't fail, and that style is imported and in use.
+ uno::Reference<style::XStyle> xStyle(getStyles("CellStyles")->getByName("Default Style.1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xStyle->isInUse());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffff00), getProperty<sal_Int32>(xStyle, "BackColor"));
+}
+
+DECLARE_ODFEXPORT_TEST(testTdf129568ui, "tdf129568-ui.fodt")
+{
+ // Same as above, but styles referenced by UI name.
+ uno::Reference<style::XStyle> xStyle(getStyles("CellStyles")->getByName("Default Style.1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xStyle->isInUse());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffff00), getProperty<sal_Int32>(xStyle, "BackColor"));
+}
+
DECLARE_ODFEXPORT_TEST(testImageMimetype, "image-mimetype.odt")
{
// Test that the loext:mimetype attribute is written for exported images, tdf#109202