fdo#47764 fix RTF import of automatic paragraph background color

Change-Id: I4b3a4bd6ce45cffc5b2c23052c49ff98579c5564
This commit is contained in:
Miklos Vajna
2012-05-02 17:50:55 +02:00
parent 042da09216
commit e8706d7a11
3 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
{\rtf1
\cbpat0\cf0
bug
}

View File

@@ -91,6 +91,7 @@ public:
void testFdo48193();
void testFdo44211();
void testFdo48037();
void testFdo47764();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -120,6 +121,7 @@ public:
CPPUNIT_TEST(testFdo48193);
CPPUNIT_TEST(testFdo44211);
CPPUNIT_TEST(testFdo48037);
CPPUNIT_TEST(testFdo47764);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -660,6 +662,20 @@ void Test::testFdo48037()
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
}
void Test::testFdo47764()
{
load("fdo47764.rtf");
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
sal_Int32 nValue = 0;
// \cbpat with zero argument should mean the auto (-1) color, not a default color (black)
xPropertySet->getPropertyValue("ParaBackColor") >>= nValue;
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), nValue);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();

View File

@@ -2331,6 +2331,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_CBPAT:
if (nParam)
{
RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_sprm::LN_PShd, NS_ooxml::LN_CT_Shd_fill, pValue);