tdf#138345 ms formats Char highlight: no import into char-style
MS Word ignores w:highlight in character styles,
so don't import it.
RES_CHRATR_HIGHLIGHT only exists in LO in order
to support Microsoft's terrible idea of allowing
two different attributes to define char background colour.
So it should be safe to remove it from UNO.
Change-Id: Ia2ee0bd61ee59dfa864e946024c8184747aa2b40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106183
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index bb95218..732c043 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -613,7 +613,7 @@ void Test::testCharStyleHighlight()
const sal_Int32 nBackColor(0xFFDBB6); //orange-y
// Always export character style's background colour as shading, never as highlighting.
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xCharStyle,"CharHighlight"));
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), false, hasProperty(xCharStyle,"CharHighlight"));
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nBackColor, getProperty<sal_Int32>(xCharStyle,"CharBackColor"));
}
}
diff --git a/sw/qa/extras/ooxmlexport/data/tdf138345_charStyleHighlight.docx b/sw/qa/extras/ooxmlexport/data/tdf138345_charStyleHighlight.docx
new file mode 100644
index 0000000..14c9aac
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf138345_charStyleHighlight.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 1170bdc..2b1b18a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -731,6 +731,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf137683_charHighlightTests, "tdf137683_charHighli
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharHighlight"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf138345_charStyleHighlight, "tdf138345_charStyleHighlight.docx")
{
// MS Word ignores the w:highlight setting in character styles. So shall we.
// Without the fix, there would be an orange or yellow background on some words.
const uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2, "orange background"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor"));
}
DECLARE_OOXMLEXPORT_TEST(testTdf134063, "tdf134063.docx")
{
CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 5e0124e..14991fa 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -79,7 +79,7 @@ DECLARE_WW8EXPORT_TEST(testTdf138345_paraCharHighlight, "tdf138345_paraCharHighl
xRun.set(getRun(getParagraph(9), 2), uno::UNO_QUERY_THROW);
// Character style formatting must not contain a highlight setting at all.
//CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharHighlight"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharHighlight"));
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharBackColor"));
}
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index f9474dc..d3fb8b9 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -185,7 +185,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetCharStylePropertyMa
{ u"" UNO_NAME_CHAR_AUTO_KERNING, RES_CHRATR_AUTOKERN , cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
{ u"" UNO_NAME_CHAR_BACK_TRANSPARENT, RES_CHRATR_BACKGROUND, cppu::UnoType<bool>::get(), PROPERTY_NONE ,MID_GRAPHIC_TRANSPARENT },
{ u"" UNO_NAME_CHAR_BACK_COLOR, RES_CHRATR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE ,MID_BACK_COLOR },
{ u"" UNO_NAME_CHAR_HIGHLIGHT, RES_CHRATR_HIGHLIGHT, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, MID_BACK_COLOR },
// RES_CHRATR_HIGHLIGHT was only here for MS compatibility, but MS ignores highlighting in char-styles
{ u"" UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},
{ u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
{ u"" UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index adbfaf2..0f812f9 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -4115,6 +4115,10 @@ void SwWW8ImplReader::Read_TextBackColor(sal_uInt16, const sal_uInt8* pData, sho
void SwWW8ImplReader::Read_CharHighlight(sal_uInt16, const sal_uInt8* pData, short nLen)
{
// MS Word completely ignores character highlighting in character styles.
if ( m_pCurrentColl && m_pCurrentColl->Which() == RES_CHRFMT )
return;
if (nLen < 1)
{
m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_HIGHLIGHT );
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 91b68dd..aff8626 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1602,6 +1602,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
break;
case NS_ooxml::LN_EG_RPrBase_highlight:
{
// MS Word completely ignores character highlighting in character styles.
if ( IsStyleSheetImport() )
{
const StyleSheetEntryPtr pCurrStyle = GetStyleSheetTable()->GetCurrentEntry();
if ( pCurrStyle && pCurrStyle->nStyleTypeCode == STYLE_TYPE_CHAR )
break;
}
// OOXML import uses an ID
if( IsOOXMLImport() )
{