Kaydet (Commit) 89206c47 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

bnc#862510: PPTX import: Wrong text color inside shape

When theme index is 0, it means it's unset so we should not
apply that.

Change-Id: I62a9cd2a9b4c19f5acffc334d5e8263fe24fc8fd
üst 0c3d5fb0
...@@ -1042,11 +1042,14 @@ Reference< XShape > Shape::createAndInsert( ...@@ -1042,11 +1042,14 @@ Reference< XShape > Shape::createAndInsert(
TextCharacterProperties aCharStyleProperties; TextCharacterProperties aCharStyleProperties;
if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) ) if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
{ {
if( pTheme ) if( pFontRef->mnThemedIdx != 0 )
if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) ) {
aCharStyleProperties.assignUsed( *pCharProps ); if( pTheme )
SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "use font color"); if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
aCharStyleProperties.maCharColor.assignIfUsed( pFontRef->maPhClr ); aCharStyleProperties.assignUsed( *pCharProps );
SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "use font color");
aCharStyleProperties.maCharColor.assignIfUsed( pFontRef->maPhClr );
}
} }
Reference < XTextCursor > xAt = xText->createTextCursor(); Reference < XTextCursor > xAt = xText->createTextCursor();
......
...@@ -89,6 +89,7 @@ public: ...@@ -89,6 +89,7 @@ public:
void testBnc584721_4(); void testBnc584721_4();
void testBnc904423(); void testBnc904423();
void testShapeLineStyle(); void testShapeLineStyle();
void testBnc862510_6();
CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST_SUITE(SdImportTest);
CPPUNIT_TEST(testDocumentLayout); CPPUNIT_TEST(testDocumentLayout);
...@@ -118,6 +119,7 @@ public: ...@@ -118,6 +119,7 @@ public:
CPPUNIT_TEST(testBnc584721_4); CPPUNIT_TEST(testBnc584721_4);
CPPUNIT_TEST(testBnc904423); CPPUNIT_TEST(testBnc904423);
CPPUNIT_TEST(testShapeLineStyle); CPPUNIT_TEST(testShapeLineStyle);
CPPUNIT_TEST(testBnc862510_6);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -993,6 +995,44 @@ void SdImportTest::testShapeLineStyle() ...@@ -993,6 +995,44 @@ void SdImportTest::testShapeLineStyle()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdImportTest::testBnc862510_6()
{
// Black text was imported instead of gray
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_6.pptx"), PPTX);
uno::Reference< drawing::XDrawPagesSupplier > xDoc(
xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
uno::Reference< drawing::XDrawPage > xPage(
xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xShape(
xPage->getByIndex(0), uno::UNO_QUERY );
CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
// Get first paragraph of the text
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
uno::Reference<container::XEnumerationAccess> paraEnumAccess;
paraEnumAccess.set(xText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
uno::UNO_QUERY_THROW);
// Get first run of the paragraph
uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
sal_Int32 nCharColor;
xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
// Color should be black
CPPUNIT_ASSERT_EQUAL( sal_Int32(0x8B8B8B), nCharColor );
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment