diff options
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt | bin | 0 -> 13816 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 35 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 5 |
3 files changed, 38 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt b/sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt Binary files differnew file mode 100644 index 000000000000..1d6f1a5f22fe --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf47471_paraStyleBackground.odt diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 0ab26ac25485..67aa3b7d7145 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -34,6 +34,7 @@ class SwUiWriterTest2 : public SwModelTestBase public: void testRedlineMoveInsertInDelete(); void testRedlineInHiddenSection(); + void testTdf47471_paraStyleBackground(); void testTdf101534(); void testTdf54819(); void testTdf108687_tabstop(); @@ -45,6 +46,7 @@ public: CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST(testRedlineMoveInsertInDelete); CPPUNIT_TEST(testRedlineInHiddenSection); + CPPUNIT_TEST(testTdf47471_paraStyleBackground); CPPUNIT_TEST(testTdf101534); CPPUNIT_TEST(testTdf54819); CPPUNIT_TEST(testTdf108687_tabstop); @@ -87,6 +89,39 @@ SwDoc* SwUiWriterTest2::createDoc(const char* pName) return pTextDoc->GetDocShell()->GetDoc(); } +void SwUiWriterTest2::testTdf47471_paraStyleBackground() +{ + SwDoc* pDoc = createDoc("tdf47471_paraStyleBackground.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + CPPUNIT_ASSERT_EQUAL(OUString("00Background"), + getProperty<OUString>(getParagraph(2), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(14729933), getProperty<sal_Int32>(getParagraph(2), "FillColor")); + + pWrtShell->EndPara(/*bSelect=*/true); + pWrtShell->EndPara(/*bSelect=*/true); + pWrtShell->EndPara(/*bSelect=*/true); + lcl_dispatchCommand(mxComponent, ".uno:ResetAttributes", {}); + + // the background color should revert to the color for 00Background style + //CPPUNIT_ASSERT_EQUAL(sal_Int32(14605542), getProperty<sal_Int32>(getParagraph(2), "FillColor")); + // the paragraph style should not be reset + CPPUNIT_ASSERT_EQUAL(OUString("00Background"), + getProperty<OUString>(getParagraph(2), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(OUString("00Background"), + getProperty<OUString>(getParagraph(3), "ParaStyleName")); + + // Save it and load it back. + reload("writer8", "tdf47471_paraStyleBackgroundRT.odt"); + + //CPPUNIT_ASSERT_EQUAL(sal_Int32(14605542), getProperty<sal_Int32>(getParagraph(2), "FillColor")); + // on round-trip, the paragraph style name was lost + CPPUNIT_ASSERT_EQUAL(OUString("00Background"), + getProperty<OUString>(getParagraph(2), "ParaStyleName")); + CPPUNIT_ASSERT_EQUAL(OUString("00Background"), + getProperty<OUString>(getParagraph(3), "ParaStyleName")); +} + void SwUiWriterTest2::testTdf101534() { // Copy the first paragraph of the document. diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index c59198bb92b3..9a7776eec9e3 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -1941,8 +1941,9 @@ void XMLTextParagraphExport::exportParagraph( } } - OUString sAutoStyle( sStyle ); - sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle ); + OUString sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle ); + if ( sAutoStyle.isEmpty() ) + sAutoStyle = sStyle; if( !sAutoStyle.isEmpty() ) GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sAutoStyle ) ); |