tdf#137683 writerfilter Char highlight: import "none"

Importing a charHighlight of NONE is critical,
since charHighlight can be set on a higher para-style,
and so there needs to be a way to cancel it with
direct formatting.

DOC already imports NONE. This adds it for RTF and DOCX.

(None of the formats EXPORT it though. So that needs to
be done, but try not to spam NONE settings where
they are not necessary, please.)

Change-Id: Ic5d03ceb81a3a079c827b81561deb9068ae8259e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106314
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf137683_charHighlightTests.docx b/sw/qa/extras/ooxmlexport/data/tdf137683_charHighlightTests.docx
new file mode 100644
index 0000000..7d1e3be
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf137683_charHighlightTests.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 0425e05..65baba8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -719,6 +719,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf136441_commentInFootnote, "tdf136441_
    // (MS Word's UI doesn't allow adding comments to a footnote.)
}

DECLARE_OOXMLEXPORT_TEST(testTdf137683_charHighlightTests, "tdf137683_charHighlightTests.docx")
{
    uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(10), 2, "no highlight"), uno::UNO_QUERY_THROW);
    // This test was failing with a cyan charHighlight of 65535 (0x00FFFF), instead of COL_TRANSPARENT (0xFFFFFFFF)
    if ( !mbExported ) //TODO: export COL_TRANSPARENT
        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_AUTO), getProperty<sal_Int32>(xRun, "CharHighlight"));
}

DECLARE_OOXMLEXPORT_TEST(testTdf134063, "tdf134063.docx")
{
    CPPUNIT_ASSERT_EQUAL(2, getPages());
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index aac420a..91b68dd 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3801,7 +3801,7 @@ void DomainMapper::handleParaJustification(const sal_Int32 nIntValue, const ::to
bool DomainMapper::getColorFromId(const Id nId, sal_Int32 &nColor)
{
    nColor = 0;
    if ((nId < NS_ooxml::LN_Value_ST_HighlightColor_black) || (nId > NS_ooxml::LN_Value_ST_HighlightColor_lightGray))
    if ((nId < NS_ooxml::LN_Value_ST_HighlightColor_black) || (nId > NS_ooxml::LN_Value_ST_HighlightColor_none))
        return false;

    switch (nId)
@@ -3822,6 +3822,7 @@ bool DomainMapper::getColorFromId(const Id nId, sal_Int32 &nColor)
    case NS_ooxml::LN_Value_ST_HighlightColor_darkYellow: nColor=0x808000; break;
    case NS_ooxml::LN_Value_ST_HighlightColor_darkGray: nColor=0x808080; break;
    case NS_ooxml::LN_Value_ST_HighlightColor_lightGray: nColor=0xC0C0C0; break;
    case NS_ooxml::LN_Value_ST_HighlightColor_none: nColor=0xFFFFFFFF; break; //COL_AUTO
    default:
        return false;
    }