summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-11-19 22:13:04 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-12-02 12:13:48 +0100
commit20574b4023952c8fbfa728590f3bdcf603633cca (patch)
tree8a4e6ab12320a327f265668537b35d9b30f43777
parente32cebc36be252d9a72c700d31b9dbbb11b58b91 (diff)
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>
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf138345_charStyleHighlight.docxbin0 -> 4434 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx9
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx2
-rw-r--r--sw/source/core/unocore/unomap1.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx4
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx8
7 files changed, 24 insertions, 3 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index bb9521823783..732c0438da5b 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 000000000000..14c9aac9ffc7
--- /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 1170bdc44d11..2b1b18aa85f9 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 5e0124e9aad4..14991fa89484 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 f9474dc92e27..d3fb8b909608 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 adbfaf20bae3..0f812f917a0c 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 91b68dd1db77..aff86268b215 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() )
{