sw/qa/extras/ooxmlexport/data/tdf135774_numberingShading.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 28 ++++++++++ writerfilter/source/dmapper/NumberingManager.cxx | 3 - 3 files changed, 29 insertions(+), 2 deletions(-)
New commits: commit 43436ef43132eb3ee6c10c0fe50971062677682a Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Mar 2 07:46:47 2021 +0200 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Sat Mar 6 12:16:45 2021 +0100 tdf#135774 writerfilter Char highlight: revert tdf#117137 revert my 6.1 commit ac27f4e7abf5339f71d4f5f3fc09a13b25669fe4 tdf#117137: DOCX import: don't try to set grab-bag as UNO prop The ultimate problems in bug 117137 seem to have been fixed elsewhere and the unit test still passes after the revert. (Tested in Word 2016 and 2003). Also my entire tone was one of uncertainty in the review process. In general, the grabbags should not be ignored, as they are supposed to just contain import information that should be exported again. In this specific case, CharGrabBag is needed to identify that the background was imported as shading, so that it will still be exported as shading instead of being converted into a highlight. If this revert causes problems, then the grabbag will need to remove the problematic items (or keep only the essential items). Change-Id: I368fcdfca9057426aa6352f1caa7b552d87905d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111937 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf135774_numberingShading.docx b/sw/qa/extras/ooxmlexport/data/tdf135774_numberingShading.docx new file mode 100644 index 000000000000..9f62ef2a5a21 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135774_numberingShading.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index b7af0c5e69b2..5555a819c00e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <editeng/escapementitem.hxx> +#include <unotools/fltrcfg.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/"; @@ -27,6 +28,24 @@ class Test : public SwModelTestBase public: Test() : SwModelTestBase(DATA_DIRECTORY, "Office Open XML Text") {} +virtual std::unique_ptr<Resetter> preTest(const char* filename) override + { + if (OString(filename) == "tdf135774_numberingShading.docx") + { + bool bIsExportAsShading = SvtFilterOptions::Get().IsCharBackground2Shading(); + // This function is run at the end of the test - returning the filter options to normal. + std::unique_ptr<Resetter> pResetter(new Resetter( + [bIsExportAsShading] () { + if (bIsExportAsShading) + SvtFilterOptions::Get().SetCharBackground2Shading(); + })); + // For these tests, ensure exporting CharBackground as w:highlight. + SvtFilterOptions::Get().SetCharBackground2Highlighting(); + return pResetter; + } + return nullptr; + } + protected: /** * Denylist handling @@ -104,6 +123,15 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf134619_numberingProps, "tdf134619_num CPPUNIT_ASSERT_EQUAL(72.f, getProperty<float>(xStyle, "CharHeight")); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf135773_numberingShading, "tdf135774_numberingShading.docx") +{ + // This test uses preTest to export CharBackground as Highlight instead of the 7.0 default of Shading. + + // Before the fix, the imported shading was converted into a red highlight. + xmlDocUniquePtr pXmlStyles = parseExport("word/numbering.xml"); + assertXPath(pXmlStyles, "/w:numbering/w:abstractNum[@w:abstractNumId='1']/w:lvl[@w:ilvl='0']/w:rPr/w:shd", "fill", "ED4C05"); +} + DECLARE_OOXMLEXPORT_TEST(testTdf139580, "tdf139580.odt") { // Without the fix in place, this test would have crashed at export time diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index 2143f3b2f04c..ac8a9a4216eb 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -165,10 +165,9 @@ static bool IgnoreForCharStyle(std::u16string_view aStr, const bool bIsSymbol) //Names found in PropertyIds.cxx, Lines 56-396 return (aStr==u"Adjust" || aStr==u"IndentAt" || aStr==u"FirstLineIndent" || aStr==u"FirstLineOffset" || aStr==u"LeftMargin" - || aStr==u"CharInteropGrabBag" || aStr==u"ParaInteropGrabBag" || // We need font names when they are different for the bullet and for the text. // But leave symbols alone, we only want to keep the font style for letters and numbers. - (bIsSymbol && aStr==u"CharFontName") + || (bIsSymbol && aStr==u"CharFontName") ); } uno::Sequence< beans::PropertyValue > ListLevel::GetCharStyleProperties( ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits