diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx index 728dd218cb65..359c051fb0df 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx @@ -301,6 +301,29 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlDateDataBinding) // i.e. the date was from document.xml, which is considered outdated. CPPUNIT_ASSERT_EQUAL(OUString("4/26/2012"), xParagraph->getString()); } + +CPPUNIT_TEST_FIXTURE(Test, testContentControlDataBindingColor) +{ + // Given a document with an inline content control with data binding, placeholder char color is + // set to red, when loading that document: + loadFromURL(u"content-control-data-binding-color.docx"); + + // Then make sure that the placeholder char color is not in the document, since data binding is + // active: + uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference xText = xTextDocument->getText(); + uno::Reference xCursor = xText->createTextCursor(); + xCursor->gotoEnd(/*bExpand=*/false); + xCursor->goLeft(/*nCount=*/1, /*bExpand=*/false); + uno::Reference xCursorProps(xCursor, uno::UNO_QUERY); + Color nColor; + CPPUNIT_ASSERT(xCursorProps->getPropertyValue("CharColor") >>= nColor); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: rgba[ffffff00] + // - Actual : rgba[ff0000ff] + // i.e. the char color was red, not the default / automatic. + CPPUNIT_ASSERT_EQUAL(COL_AUTO, nColor); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/content-control-data-binding-color.docx b/writerfilter/qa/cppunittests/dmapper/data/content-control-data-binding-color.docx new file mode 100644 index 000000000000..0aae9439209b Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/content-control-data-binding-color.docx differ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 46260200d7a1..f5f8f70d732c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -916,6 +916,13 @@ void DomainMapper_Impl::PopSdt() { // Data binding has a value for us, prefer that over the in-document value. xCursor->setString(*oData); + + // Such value is always a plain text string, remove the char style of the placeholder. + uno::Reference xPropertyState(xCursor, uno::UNO_QUERY); + if (xPropertyState.is()) + { + xPropertyState->setPropertyToDefault("CharStyleName"); + } } uno::Reference xContentControl(