diff options
author | Adam Co <rattles2013@gmail.com> | 2013-06-23 10:49:28 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-06-25 10:04:01 +0200 |
commit | 26d40686128e70916a636e20f5ccc5763bbb6cc8 (patch) | |
tree | bf4fa4f957f84482b66fe0bac2197e43ada91a70 /sw | |
parent | b3962c92bfb8d14d908bfeb9142548e9686ee105 (diff) |
fdo65400: fix for Character Shading being lost
This bug fixes the DOCX import and export filters, adds a new property
to the document model and updates the UNO API.
There is no need to add layout \ UI updates, because in Word
the only way to turn this on\off is using a simple button,
and there is no way to control the shading color itself.
However, ODF import \ export filters should be updated in a future
commit.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I1d34cec79289e38c08e42a4c6265d998e1edfdef
Reviewed-on: https://gerrit.libreoffice.org/4452
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unoprnms.hxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo65400.docx | bin | 0 -> 16108 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/unocore/unoprnms.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 21 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 135 |
7 files changed, 107 insertions, 72 deletions
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index fb6e9d372adf..68a1f4b011cd 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -822,7 +822,9 @@ enum SwPropNameIds /* 0760 */ UNO_NAME_DEFAULT_PAGE_MODE, -/* 0761 */ SW_PROPNAME_END +/* 0761 */ UNO_NAME_CHAR_SHADING_VALUE, + +/* 0762 */ SW_PROPNAME_END // new items in this array must match SwPropNameTab aPropNameTab }; diff --git a/sw/qa/extras/ooxmlexport/data/fdo65400.docx b/sw/qa/extras/ooxmlexport/data/fdo65400.docx Binary files differnew file mode 100644 index 000000000000..c247e9fff8f2 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo65400.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index b4d855a4c347..db12382b32e2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -84,6 +84,7 @@ public: void testFdo64238_a(); void testFdo64238_b(); void testFdo56679(); + void testFdo65400(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -142,6 +143,7 @@ void Test::run() {"fdo64238_a.docx", &Test::testFdo64238_a}, {"fdo64238_b.docx", &Test::testFdo64238_b}, {"fdo56679.docx", &Test::testFdo56679}, + {"fdo65400.docx", &Test::testFdo65400}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -865,6 +867,17 @@ void Test::testFdo56679() CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), getProperty<sal_Int32>(xText, "CharUnderlineColor")); } +void Test::testFdo65400() +{ + // The problem was that if in Word you choose 'Character Shading' - then the text portion + // is marked with 'w:shd val=pct15'. LO did not store this value and so when importing and exporting + // this value was lost (and so Word did not show 'Character Shading' was on) + uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 ); + uno::Reference< text::XTextRange > shaded = getRun( paragraph1, 2, "normal" ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty< sal_Int32 >( shaded, "CharShadingValue" )); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty< sal_Int32 >( shaded, "CharBackColor" )); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 8a0bc615a9b3..da8857c1206f 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -234,7 +234,8 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider() { SW_PROP_NMID(UNO_NAME_CHAR_RELIEF), RES_CHRATR_RELIEF, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, MID_RELIEF }, \ { SW_PROP_NMID(UNO_NAME_SNAP_TO_GRID), RES_PARATR_SNAPTOGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0 }, \ { SW_PROP_NMID(UNO_NAME_PARA_IS_CONNECT_BORDER), RES_PARATR_CONNECT_BORDER, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0}, \ - { SW_PROP_NMID(UNO_NAME_WRITING_MODE), RES_FRAMEDIR, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, 0 }, + { SW_PROP_NMID(UNO_NAME_WRITING_MODE), RES_FRAMEDIR, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, 0 }, \ + { SW_PROP_NMID(UNO_NAME_CHAR_SHADING_VALUE), RES_CHRATR_BACKGROUND, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_SHADING_VALUE }, #define COMMON_CRSR_PARA_PROPERTIES_WITHOUT_FN \ COMMON_CRSR_PARA_PROPERTIES_WITHOUT_FN_01 \ diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx index f28e927ee4cf..8e1c7ce8b844 100644 --- a/sw/source/core/unocore/unoprnms.cxx +++ b/sw/source/core/unocore/unoprnms.cxx @@ -789,7 +789,8 @@ const SwPropNameTab aPropNameTab = { /* 0757 UNO_NAME_FILL_STYLE */ {MAP_CHAR_LEN("FillStyle")}, /* 0758 UNO_NAME_FILL_GRADIENT */ {MAP_CHAR_LEN("FillGradient")}, /* 0759 UNO_NAME_FILL_GRADIENT_NAME */ {MAP_CHAR_LEN("FillGradientName")}, -/* 0760 UNO_NAME_DEFAULT_PAGE_MODE */ {MAP_CHAR_LEN("DefaultPageMode")} +/* 0760 UNO_NAME_DEFAULT_PAGE_MODE */ {MAP_CHAR_LEN("DefaultPageMode")}, +/* 0761 UNO_NAME_CHAR_SHADING_VALUE */ {MAP_CHAR_LEN("CharShadingValue")}, // new items in this array must match enum SwPropNameIds }; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ddda9ddae7a2..03e717b5e80b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -103,6 +103,7 @@ #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/drawing/ShadingPattern.hpp> #if OSL_DEBUG_LEVEL > 1 #include <stdio.h> @@ -117,6 +118,7 @@ using namespace nsSwDocInfoSubType; using namespace nsFieldFlags; using namespace sw::util; using namespace ::com::sun::star; +using namespace ::com::sun::star::drawing; class FFDataWriterHelper { @@ -3713,12 +3715,29 @@ void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink ) m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS( XML_w, XML_val ), "none", FSEND ); } +#define MSWORD_CH_SHADING_CLR 0xD8D8D8 // This color is the same color as the ms-word's character shading color. +#define MSWORD_CH_SHADING_FILL "FFFFFF" // The attribute w:fill of w:shd, for MS-Word's character shading, +#define MSWORD_CH_SHADING_COLOR "auto" // The attribute w:color of w:shd, for MS-Word's character shading, +#define MSWORD_CH_SHADING_VAL "pct15" // The attribute w:value of w:shd, for MS-Word's character shading, + void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush ) { - m_pSerializer->singleElementNS( XML_w, XML_shd, + // Check if the brush shading pattern is 'PCT15'. If so - write it back to the DOCX + if (rBrush.GetShadingValue() == ShadingPattern::PCT15) + { + m_pSerializer->singleElementNS( XML_w, XML_shd, + FSNS( XML_w, XML_val ), MSWORD_CH_SHADING_VAL, + FSNS( XML_w, XML_color ), MSWORD_CH_SHADING_COLOR, + FSNS( XML_w, XML_fill ), MSWORD_CH_SHADING_FILL, + FSEND ); + } + else + { + m_pSerializer->singleElementNS( XML_w, XML_shd, FSNS( XML_w, XML_fill ), msfilter::util::ConvertColor( rBrush.GetColor() ).getStr(), FSNS( XML_w, XML_val ), "clear", FSEND ); + } } void DocxAttributeOutput::CharFontCJK( const SvxFontItem& rFont ) diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 0d9a6388d992..6435e3ca778d 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -4449,75 +4449,74 @@ void SwWW8Shade::SetShade(ColorData nFore, ColorData nBack, sal_uInt16 nIndex) { static const sal_uLong eMSGrayScale[] = { - // Nul-Brush - 0, // 0 + // Clear-Brush + 0, // 0 clear // Solid-Brush - 1000, // 1 - // promillemaessig abgestufte Schattierungen - 50, // 2 - 100, // 3 - 200, // 4 - 250, // 5 - 300, // 6 - 400, // 7 - 500, // 8 - 600, // 9 - 700, // 10 - 750, // 11 - 800, // 12 - 900, // 13 - 333, // 14 Dark Horizontal - 333, // 15 Dark Vertical - 333, // 16 Dark Forward Diagonal - 333, // 17 Dark Backward Diagonal - 333, // 18 Dark Cross - 333, // 19 Dark Diagonal Cross - 333, // 20 Horizontal - 333, // 21 Vertical - 333, // 22 Forward Diagonal - 333, // 23 Backward Diagonal - 333, // 24 Cross - 333, // 25 Diagonal Cross - // neun Nummern ohne Bedeutung in Ver8 - 500, // 26 - 500, // 27 - 500, // 28 - 500, // 29 - 500, // 30 - 500, // 31 - 500, // 32 - 500, // 33 - 500, // 34 - // und weiter gehts mit tollen Schattierungen ;-) - 25, // 35 - 75, // 36 - 125, // 37 - 150, // 38 - 175, // 39 - 225, // 40 - 275, // 41 - 325, // 42 - 350, // 43 - 375, // 44 - 425, // 45 - 450, // 46 - 475, // 47 - 525, // 48 - 550, // 49 - 575, // 50 - 625, // 51 - 650, // 52 - 675, // 53 - 725, // 54 - 775, // 55 - 825, // 56 - 850, // 57 - 875, // 58 - 925, // 59 - 950, // 60 - 975, // 61 - // und zu guter Letzt: - 970 + 1000, // 1 solid + // Percent values + 50, // 2 pct5 + 100, // 3 pct10 + 200, // 4 pct20 + 250, // 5 pct25 + 300, // 6 pct30 + 400, // 7 pct40 + 500, // 8 pct50 + 600, // 9 pct60 + 700, // 10 pct70 + 750, // 11 pct75 + 800, // 12 pct80 + 900, // 13 pct90 + // Special cases + 333, // 14 Dark Horizontal + 333, // 15 Dark Vertical + 333, // 16 Dark Forward Diagonal + 333, // 17 Dark Backward Diagonal + 333, // 18 Dark Cross + 333, // 19 Dark Diagonal Cross + 333, // 20 Horizontal + 333, // 21 Vertical + 333, // 22 Forward Diagonal + 333, // 23 Backward Diagonal + 333, // 24 Cross + 333, // 25 Diagonal Cross + // Undefined values in DOC spec-sheet + 500, // 26 + 500, // 27 + 500, // 28 + 500, // 29 + 500, // 30 + 500, // 31 + 500, // 32 + 500, // 33 + 500, // 34 + // Different shading types + 25, // 35 [available in DOC, not available in DOCX] + 75, // 36 [available in DOC, not available in DOCX] + 125, // 37 pct12 + 150, // 38 pct15 + 175, // 39 [available in DOC, not available in DOCX] + 225, // 40 [available in DOC, not available in DOCX] + 275, // 41 [available in DOC, not available in DOCX] + 325, // 42 [available in DOC, not available in DOCX] + 350, // 43 pct35 + 375, // 44 pct37 + 425, // 45 [available in DOC, not available in DOCX] + 450, // 46 pct45 + 475, // 47 [available in DOC, not available in DOCX] + 525, // 48 [available in DOC, not available in DOCX] + 550, // 49 pct55 + 575, // 50 [available in DOC, not available in DOCX] + 625, // 51 pct62 + 650, // 52 pct65 + 675, // 53 [available in DOC, not available in DOCX] + 725, // 54 [available in DOC, not available in DOCX] + 775, // 55 [available in DOC, not available in DOCX] + 825, // 56 [available in DOC, not available in DOCX] + 850, // 57 pct85 + 875, // 58 pct87 + 925, // 59 [available in DOC, not available in DOCX] + 950, // 60 pct95 + 975 // 61 [available in DOC, not available in DOCX] };// 62 |