diff options
author | Adam Co <rattles2013@gmail.com> | 2013-06-23 18:17:49 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-06-24 09:34:18 +0000 |
commit | 6edcfde748604863dba40e982effab38d0cb0589 (patch) | |
tree | d40aae4520b6277222b9f76c7917f316462f9f4b | |
parent | a659ac906aa2d0dfd6d10e40d8a5a6d2d70cc8fc (diff) |
fdo#56679, fdo#65710 : fix for import and export of underline color
Change-Id: Ifc45900d73802ef99c55d7af4ee04314dd04f1c5
Reviewed-on: https://gerrit.libreoffice.org/4459
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
Tested-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo56679.docx | bin | 0 -> 15993 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 52 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 8 |
4 files changed, 52 insertions, 21 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo56679.docx b/sw/qa/extras/ooxmlexport/data/fdo56679.docx Binary files differnew file mode 100644 index 000000000000..8ea689c3c57c --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo56679.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 133cf6e220b0..b4d855a4c347 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -83,6 +83,7 @@ public: void testFdo43093(); void testFdo64238_a(); void testFdo64238_b(); + void testFdo56679(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -140,6 +141,7 @@ void Test::run() {"fdo43093.docx", &Test::testFdo43093}, {"fdo64238_a.docx", &Test::testFdo64238_a}, {"fdo64238_b.docx", &Test::testFdo64238_b}, + {"fdo56679.docx", &Test::testFdo56679}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -852,6 +854,17 @@ void Test::testFdo64238_b() CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns); } +void Test::testFdo56679() +{ + // The problem was that the DOCX importer and exporter did not handle the 'color' of an underline + // (not the color of the text, the color of the underline itself) + uno::Reference< text::XTextRange > xParagraph = getParagraph( 1 ); + uno::Reference< text::XTextRange > xText = getRun( xParagraph, 2, "This is a simple sentence."); + + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xText, "CharUnderlineHasColor"))); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), getProperty<sal_Int32>(xText, "CharUnderlineColor")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 254b0bf7691e..ddda9ddae7a2 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3651,31 +3651,45 @@ void DocxAttributeOutput::CharShadow( const SvxShadowedItem& rShadow ) void DocxAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline ) { - const char *pUnderline; + const char *pUnderlineValue; switch ( rUnderline.GetLineStyle() ) { - case UNDERLINE_SINGLE: pUnderline = "single"; break; - case UNDERLINE_BOLD: pUnderline = "thick"; break; - case UNDERLINE_DOUBLE: pUnderline = "double"; break; - case UNDERLINE_DOTTED: pUnderline = "dotted"; break; - case UNDERLINE_DASH: pUnderline = "dash"; break; - case UNDERLINE_DASHDOT: pUnderline = "dotDash"; break; - case UNDERLINE_DASHDOTDOT: pUnderline = "dotDotDash"; break; - case UNDERLINE_WAVE: pUnderline = "wave"; break; - case UNDERLINE_BOLDDOTTED: pUnderline = "dottedHeavy"; break; - case UNDERLINE_BOLDDASH: pUnderline = "dashedHeavy"; break; - case UNDERLINE_LONGDASH: pUnderline = "dashLongHeavy"; break; - case UNDERLINE_BOLDLONGDASH: pUnderline = "dashLongHeavy"; break; - case UNDERLINE_BOLDDASHDOT: pUnderline = "dashDotHeavy"; break; - case UNDERLINE_BOLDDASHDOTDOT: pUnderline = "dashDotDotHeavy"; break; - case UNDERLINE_BOLDWAVE: pUnderline = "wavyHeavy"; break; - case UNDERLINE_DOUBLEWAVE: pUnderline = "wavyDouble"; break; + case UNDERLINE_SINGLE: pUnderlineValue = "single"; break; + case UNDERLINE_BOLD: pUnderlineValue = "thick"; break; + case UNDERLINE_DOUBLE: pUnderlineValue = "double"; break; + case UNDERLINE_DOTTED: pUnderlineValue = "dotted"; break; + case UNDERLINE_DASH: pUnderlineValue = "dash"; break; + case UNDERLINE_DASHDOT: pUnderlineValue = "dotDash"; break; + case UNDERLINE_DASHDOTDOT: pUnderlineValue = "dotDotDash"; break; + case UNDERLINE_WAVE: pUnderlineValue = "wave"; break; + case UNDERLINE_BOLDDOTTED: pUnderlineValue = "dottedHeavy"; break; + case UNDERLINE_BOLDDASH: pUnderlineValue = "dashedHeavy"; break; + case UNDERLINE_LONGDASH: pUnderlineValue = "dashLongHeavy"; break; + case UNDERLINE_BOLDLONGDASH: pUnderlineValue = "dashLongHeavy"; break; + case UNDERLINE_BOLDDASHDOT: pUnderlineValue = "dashDotHeavy"; break; + case UNDERLINE_BOLDDASHDOTDOT: pUnderlineValue = "dashDotDotHeavy"; break; + case UNDERLINE_BOLDWAVE: pUnderlineValue = "wavyHeavy"; break; + case UNDERLINE_DOUBLEWAVE: pUnderlineValue = "wavyDouble"; break; case UNDERLINE_NONE: // fall through - default: pUnderline = "none"; break; + default: pUnderlineValue = "none"; break; } - m_pSerializer->singleElementNS( XML_w, XML_u, FSNS( XML_w, XML_val ), pUnderline, FSEND ); + Color aUnderlineColor = rUnderline.GetColor(); + bool bUnderlineHasColor = aUnderlineColor.GetTransparency() == 0; + if (bUnderlineHasColor) + { + // Underline has a color + m_pSerializer->singleElementNS( XML_w, XML_u, + FSNS( XML_w, XML_val ), pUnderlineValue, + FSNS( XML_w, XML_color ), msfilter::util::ConvertColor( aUnderlineColor ).getStr(), + FSEND ); + } + else + { + // Underline has no color + m_pSerializer->singleElementNS( XML_w, XML_u, FSNS( XML_w, XML_val ), pUnderlineValue, FSEND ); + } } void DocxAttributeOutput::CharWeight( const SvxWeightItem& rWeight ) diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index c9f2d4f962ed..e9b2d6a5d998 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -12833,11 +12833,15 @@ </list> </define> <define name="CT_Underline"> - <optional><attribute name="val"><ref name="ST_Underline"/><xs:documentation>Underline Style</xs:documentation></attribute>ST_String + <optional> + <attribute name="val"> + <ref name="ST_Underline"/> + <xs:documentation>Underline Style</xs:documentation> + </attribute> </optional> <optional> <attribute name="color"> - <text/> + <ref name="ST_HexColor"/> <xs:documentation>Underline Color</xs:documentation> </attribute> </optional> |