sw/qa/extras/ooxmlexport/data/noDefault.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 28 ++++++++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +++++ 3 files changed, 35 insertions(+)
New commits: commit a56e2bba046b569e8923a438996bc6185037d3ed Author: Justin Luth <justin_l...@sil.org> AuthorDate: Fri Jul 27 07:22:02 2018 +0300 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Sat Jul 28 06:16:38 2018 +0200 writerfilter: unit test that no w:default still uses "Normal" Note: the unit test does NOT test the changes in GetCurrentParaStyleName. That is just a logical change and this unit test asserts the validity of the intention. Word 2013 was used to confirm that Normal is used for styleless paragraphs even if it is not marked as "default". Change-Id: I405591b40ed9028b292e99ba2833c25a24e089ac Reviewed-on: https://gerrit.libreoffice.org/58161 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ooxmlexport/data/noDefault.docx b/sw/qa/extras/ooxmlexport/data/noDefault.docx new file mode 100644 index 000000000000..56bc2669110a Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/noDefault.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 5f8b5bb2a3b6..bb5d91500cb3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -479,6 +479,34 @@ DECLARE_OOXMLEXPORT_TEST(testOpenDocumentAsReadOnly, "open-as-read-only.docx") CPPUNIT_ASSERT(pTextDoc->GetDocShell()->IsSecurityOptOpenReadOnly()); } +DECLARE_OOXMLEXPORT_TEST(testNoDefault, "noDefault.docx") +{ + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + + // Row 1: color directly applied to the paragraph, overrides table and style colors + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x2E74B5), getProperty<sal_Int32>(getRun(xPara,1), "CharColor")); + + // Row2: (still part of firstRow table-style) ought to use the Normal style color, not the table-style color(5B9BD5) + //xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); + //xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + //xParaEnum = xParaEnumAccess->createEnumeration(); + //xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + //CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTMAGENTA), getProperty<sal_Int32>(getRun(xPara,1), "CharColor")); + + // Row 3+: Normal style still applied, even if nothing is specified with w:default="1" + xCell.set(xTable->getCellByName("A3"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum = xParaEnumAccess->createEnumeration(); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_LIGHTMAGENTA), getProperty<sal_Int32>(getRun(xPara,1), "CharColor")); +} + DECLARE_OOXMLEXPORT_TEST(testMarginsFromStyle, "margins_from_style.docx") { // tdf#118521 paragraphs with direct formatting of top or bottom margins have diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 6bfb6d7b65b6..469d8d0ce1fd 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -662,6 +662,13 @@ const OUString DomainMapper_Impl::GetCurrentParaStyleName() if ( pParaContext && pParaContext->isSet(PROP_PARA_STYLE_NAME) ) pParaContext->getProperty(PROP_PARA_STYLE_NAME)->second >>= sName; + // In rare situations the name might still be blank, so use the default style, + // despite documentation that states, "If this attribute is not specified for any style, + // then no properties shall be applied to objects of the specified type." + // Word, however, assigns "Normal" style even in these situations. + if ( !m_bInStyleSheetImport && sName.isEmpty() ) + sName = GetDefaultParaStyleName(); + return sName; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits