diff --git a/sw/qa/extras/ww8export/data/tdf104334.doc b/sw/qa/extras/ww8export/data/tdf104334.doc new file mode 100644 index 000000000000..877caff0c581 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf104334.doc differ diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index 6dc17cc34d90..d5050cc67285 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -74,6 +74,14 @@ DECLARE_WW8EXPORT_TEST(testTdf104805, "tdf104805.doc") } } +DECLARE_WW8EXPORT_TEST(testTdf104334, "tdf104334.doc") +{ + // This failed with a container::NoSuchElementException: STYLEREF was + // mapped to SwChapterField, and the field result was "This is a Heading 1" + // instead of just "1". + CPPUNIT_ASSERT_EQUAL(OUString("1"), getRun(getParagraph(2), 3)->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index cb14e24c7b2e..5d9606392d3d 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -914,6 +914,14 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes) if (nRet == -2 && !aReadParam.GetResult().isEmpty()) // Single numeric argument: this can be handled by SwChapterField. bHasHandler = rtl::isAsciiDigit(aReadParam.GetResult()[0]); + + if (bHasHandler) + { + nRet = aReadParam.SkipToNextToken(); + // Handle using SwChapterField only in case there is no \[a-z] + // switch after the field argument. + bHasHandler = nRet < 0 || nRet == '*'; + } } // keine Routine vorhanden