diff options
-rw-r--r-- | oox/source/drawingml/shape.cxx | 12 | ||||
-rw-r--r-- | oox/source/shape/WpsContext.cxx | 13 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/wps-char-color.docx | bin | 0 -> 15589 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 7 |
4 files changed, 31 insertions, 1 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 96b9129d3536..1aa23f78a08e 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1013,10 +1013,10 @@ Reference< XShape > Shape::createAndInsert( else if( getTextBody() ) getTextBody()->getTextProperties().pushVertSimulation(); + PropertySet aPropertySet(mxShape); if ( !bUseRotationTransform && mnRotation != 0 ) { // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx) - PropertySet aPropertySet( mxShape ); aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) ); aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) ); aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) ); @@ -1042,6 +1042,16 @@ Reference< XShape > Shape::createAndInsert( getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle ); } } + else if (mbTextBox) + { + // No drawingML text, but WPS text is expected: save the theme + // character color on the shape, then. + if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef)) + { + sal_Int32 nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper); + aPropertySet.setAnyProperty(PROP_CharColor, uno::makeAny(nCharColor)); + } + } } if( mxShape.is() ) diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index 4d5863873fd5..9e3218e5bfbc 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -111,6 +111,19 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken drawing::TextVerticalAdjust eAdjust = drawingml::GetTextVerticalAdjust(rAttribs.getToken(XML_anchor, XML_t)); xPropertySet->setPropertyValue("TextVerticalAdjust", uno::makeAny(eAdjust)); } + + // Apply character color of the shape to the shape's textbox. + uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY); + uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); + xTextCursor->gotoStart(false); + xTextCursor->gotoEnd(true); + const uno::Reference<beans::XPropertyState> xPropertyState(xTextCursor, uno::UNO_QUERY); + const beans::PropertyState ePropertyState = xPropertyState->getPropertyState("CharColor"); + if (ePropertyState == beans::PropertyState_DEFAULT_VALUE) + { + uno::Reference<beans::XPropertySet> xTextBoxPropertySet(xTextCursor, uno::UNO_QUERY); + xTextBoxPropertySet->setPropertyValue("CharColor", xPropertySet->getPropertyValue("CharColor")); + } return this; } break; diff --git a/sw/qa/extras/ooxmlexport/data/wps-char-color.docx b/sw/qa/extras/ooxmlexport/data/wps-char-color.docx Binary files differnew file mode 100644 index 000000000000..a027e92be124 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/wps-char-color.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d136875d7b7d..c5cfe7912c83 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -360,6 +360,13 @@ DECLARE_OOXMLEXPORT_TEST(testMsoPosition, "bnc884615-mso-position.docx") } } +DECLARE_OOXMLEXPORT_TEST(testWpsCharColor, "wps-char-color.docx") +{ + uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); + // This was -1, i.e. the character color was default (-1), not white. + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xShape->getStart(), "CharColor")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |