diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2022-03-22 14:02:35 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-23 09:21:35 +0100 |
commit | e5f96e2881d46ed71e390524d7172dca211de3e4 (patch) | |
tree | 605d3f793a2674119bdb4a925b4cc1a4f341568f /writerfilter | |
parent | be5ef79b93f37c6e91d0f94c647bbc42dff2abe2 (diff) |
tdf#111851: rtf import: fifty shades of grey
Unlike in DOCX in RTF token \clshdngN can represent much more
transitional cell shade values from 0 (white) to 10000 (black).
So we should not match these values strictly but use ranges
instead.
Change-Id: I4e0066e2b79e73cf6fbc3dd773047be8dab2b907
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131931
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 136 |
1 files changed, 58 insertions, 78 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index f12c90575c33..b3c04bb0f1f1 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -485,84 +485,64 @@ bool RTFDocumentImpl::dispatchTableValue(RTFKeyword nKeyword, int nParam) case RTFKeyword::CLSHDNG: { int nValue = -1; - switch (nParam) - { - case 500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct5; - break; - case 1000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct10; - break; - case 1200: - nValue = NS_ooxml::LN_Value_ST_Shd_pct12; - break; - case 1500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct15; - break; - case 2000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct20; - break; - case 2500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct25; - break; - case 3000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct30; - break; - case 3500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct35; - break; - case 3700: - nValue = NS_ooxml::LN_Value_ST_Shd_pct37; - break; - case 4000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct40; - break; - case 4500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct45; - break; - case 5000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct50; - break; - case 5500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct55; - break; - case 6000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct60; - break; - case 6200: - nValue = NS_ooxml::LN_Value_ST_Shd_pct62; - break; - case 6500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct65; - break; - case 7000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct70; - break; - case 7500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct75; - break; - case 8000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct80; - break; - case 8500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct85; - break; - case 8700: - nValue = NS_ooxml::LN_Value_ST_Shd_pct87; - break; - case 9000: - nValue = NS_ooxml::LN_Value_ST_Shd_pct90; - break; - case 9500: - nValue = NS_ooxml::LN_Value_ST_Shd_pct95; - break; - default: - break; - } - if (nValue != -1) - putNestedAttribute(m_aStates.top().getTableCellSprms(), - NS_ooxml::LN_CT_TcPrBase_shd, NS_ooxml::LN_CT_Shd_val, - new RTFValue(nValue)); + + if (nParam < 1) + nValue = NS_ooxml::LN_Value_ST_Shd_clear; + else if (nParam < 750) + // Values in between 1 and 250 visually closer to 0% shading (white) + // But this will mean "no shading" while cell actually have some. + // So lets use minimal available value. + nValue = NS_ooxml::LN_Value_ST_Shd_pct5; + else if (nParam < 1100) + nValue = NS_ooxml::LN_Value_ST_Shd_pct10; + else if (nParam < 1350) + nValue = NS_ooxml::LN_Value_ST_Shd_pct12; + else if (nParam < 1750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct15; + else if (nParam < 2250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct20; + else if (nParam < 2750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct25; + else if (nParam < 3250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct30; + else if (nParam < 3600) + nValue = NS_ooxml::LN_Value_ST_Shd_pct35; + else if (nParam < 3850) + nValue = NS_ooxml::LN_Value_ST_Shd_pct37; + else if (nParam < 4250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct40; + else if (nParam < 4750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct45; + else if (nParam < 5250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct50; + else if (nParam < 5750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct55; + else if (nParam < 6100) + nValue = NS_ooxml::LN_Value_ST_Shd_pct60; + else if (nParam < 6350) + nValue = NS_ooxml::LN_Value_ST_Shd_pct62; + else if (nParam < 6750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct65; + else if (nParam < 7250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct70; + else if (nParam < 7750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct75; + else if (nParam < 8250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct80; + else if (nParam < 8600) + nValue = NS_ooxml::LN_Value_ST_Shd_pct85; + else if (nParam < 8850) + nValue = NS_ooxml::LN_Value_ST_Shd_pct87; + else if (nParam < 9250) + nValue = NS_ooxml::LN_Value_ST_Shd_pct90; + else if (nParam < 9750) + nValue = NS_ooxml::LN_Value_ST_Shd_pct95; + else + // Solid fill + nValue = NS_ooxml::LN_Value_ST_Shd_solid; + + putNestedAttribute(m_aStates.top().getTableCellSprms(), NS_ooxml::LN_CT_TcPrBase_shd, + NS_ooxml::LN_CT_Shd_val, new RTFValue(nValue)); return true; } break; |