diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx | bin | 0 -> 31782 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 20 |
3 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx b/sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx Binary files differnew file mode 100644 index 000000000000..a465813dc668 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 5f521b8067c4..ed5216c15a10 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -633,6 +633,16 @@ DECLARE_OOXMLEXPORT_TEST(testParagraphMark, "paragraph-mark.docx") CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharStyleName")); } +DECLARE_OOXMLEXPORT_TEST(testParagraphMark2, "paragraph-mark2.docx") +{ + // The problem was that we didn't handle the situation when an empty paragraph's marker had both a char style and some direct formatting. + + // This was Segoe UI, set by Char Style FontStyle11 presumably. + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName")); + // This was 11, set by Char Style FontStyle11 presumably. + CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(getRun(getParagraph(1), 1), "CharHeight")); +} + DECLARE_OOXMLEXPORT_TEST(testParagraphMarkNonempty, "paragraph-mark-nonempty.odt") { CPPUNIT_ASSERT_EQUAL(1, getPages()); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 9ef0f55dc08c..ee5185b12f2b 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1275,6 +1275,26 @@ SwXText::Impl::finishOrAppendParagraph( aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties); + + // tdf#127616 keep direct character formatting of empty paragraphs, + // if character style of the paragraph sets also the same attributes + if (aPam.Start()->nNode.GetNode().GetTextNode()->Len() == 0) + { + auto itCharStyle = std::find_if(rProperties.begin(), rProperties.end(), [](const beans::PropertyValue& rValue) + { + return rValue.Name == "CharStyleName"; + }); + if ( itCharStyle != rProperties.end() ) + { + for (const auto& rValue : rProperties) + { + if ( rValue != *itCharStyle && rValue.Name.startsWith("Char") ) + { + SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet, rValue.Name, rValue.Value); + } + } + } + } } catch (const lang::IllegalArgumentException& rIllegal) { |