Kaydet (Commit) 7d9e9ecd authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

tdf#90906 writerfilter: Allow COL_AUTO to override non-auto

If the inherited properties define a non-auto color, then
a specified COL_AUTO needs to be returned in order to
override the inherited color.

This affects three areas. Character fill, Paragraph fill,
and table cell fill. The unit tests cover all three areas.

This patch depends on the commits for tdf#91292

Change-Id: I1a043d2224b164c6c411ce2e46d899212f2b7f3d
Reviewed-on: https://gerrit.libreoffice.org/59313
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
üst 1d4f0311
......@@ -53,6 +53,38 @@ DECLARE_OOXMLEXPORT_TEST(testTdf57589_hashColor, "tdf57589_hashColor.docx")
CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(getParagraph(2), "ParaBackColor")));
}
DECLARE_OOXMLEXPORT_TEST(testTdf90906_colAuto, "tdf90906_colAuto.docx")
{
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(getRun(xPara, 1, "Nazwa"), "CharBackColor")));
}
DECLARE_OOXMLEXPORT_TEST(testTdf90906_colAutoB, "tdf90906_colAutoB.docx")
{
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, Color(getProperty<sal_uInt32>(xCell, "BackColor")));
xCell.set(xTable->getCellByName("A2"));
CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(xCell, "BackColor")));
xCell.set(xTable->getCellByName("B1"));
CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(xCell, "BackColor")));
xCell.set(xTable->getCellByName("B2"));
CPPUNIT_ASSERT_EQUAL(COL_LIGHTBLUE, Color(getProperty<sal_uInt32>(xCell, "BackColor")));
uno::Reference<text::XTextRange> xText(getParagraph(2, "Paragraphs too"));
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xText, "FillStyle"));
CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(xText, "ParaBackColor")));
}
DECLARE_OOXMLEXPORT_TEST(testTdf92524_autoColor, "tdf92524_autoColor.doc")
{
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
......
......@@ -39,6 +39,7 @@ m_nShadingPattern( drawing::ShadingPattern::CLEAR ),
m_nColor( 0xffffffff ),
m_nFillColor( 0xffffffff ),
m_bAutoFillColor( true ),
m_bFillSpecified( false ),
m_OutputFormat( Form )
{
}
......@@ -116,6 +117,7 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
m_bAutoFillColor = false;
m_nFillColor = nIntValue;
m_bFillSpecified = true;
break;
case NS_ooxml::LN_CT_Shd_color:
createGrabBag("color", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue))));
......@@ -205,7 +207,10 @@ TablePropertyMapPtr CellColorHandler::getProperties()
if( !nWW8BrushStyle )
{
// Clear-Brush
nApplyColor = m_nFillColor;
if ( m_bFillSpecified && m_bAutoFillColor )
nApplyColor = sal_Int32(COL_AUTO);
else
nApplyColor = m_nFillColor;
}
else
{
......@@ -273,13 +278,14 @@ TablePropertyMapPtr CellColorHandler::getProperties()
if (m_OutputFormat == Paragraph)
{
// If brush style = clear and FillColor = COLOR_AUTO, then don't enable the fill style - just pre-select the default color
if (nWW8BrushStyle || !m_bAutoFillColor)
pPropertyMap->Insert(PROP_FILL_STYLE, uno::makeAny(drawing::FillStyle_SOLID));
else if ( m_bFillSpecified && m_bAutoFillColor )
pPropertyMap->Insert(PROP_FILL_STYLE, uno::makeAny(drawing::FillStyle_NONE));
pPropertyMap->Insert(PROP_FILL_COLOR, uno::makeAny(nApplyColor));
}
else if (nWW8BrushStyle || !m_bAutoFillColor)
else if ( nWW8BrushStyle || !m_bAutoFillColor || m_bFillSpecified )
pPropertyMap->Insert( m_OutputFormat == Form ? PROP_BACK_COLOR
: PROP_CHAR_BACK_COLOR, uno::makeAny( nApplyColor ));
......
......@@ -38,6 +38,7 @@ private:
sal_Int32 m_nColor;
sal_Int32 m_nFillColor;
bool m_bAutoFillColor;
bool m_bFillSpecified;
OutputFormat m_OutputFormat;
OUString m_aInteropGrabBagName;
......
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