[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

Adam Co rattles2013 at gmail.com
Mon Jun 24 02:34:38 PDT 2013


 sw/qa/extras/ooxmlexport/data/fdo56679.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   13 ++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   52 +++++++++++++++++----------
 writerfilter/source/ooxml/model.xml          |    8 +++-
 4 files changed, 52 insertions(+), 21 deletions(-)

New commits:
commit 6edcfde748604863dba40e982effab38d0cb0589
Author: Adam Co <rattles2013 at gmail.com>
Date:   Sun Jun 23 18:17:49 2013 +0300

    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 at suse.cz>
    Tested-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sw/qa/extras/ooxmlexport/data/fdo56679.docx b/sw/qa/extras/ooxmlexport/data/fdo56679.docx
new file mode 100644
index 0000000..8ea689c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo56679.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 133cf6e..b4d855a 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 254b0bf..ddda9dd 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 c9f2d4f..e9b2d6a 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>


More information about the Libreoffice-commits mailing list