oox/source/drawingml/textcharacterproperties.cxx |    1 
 oox/source/export/drawingml.cxx                  |   30 +++++++++++++----------
 sc/qa/unit/data/xlsx/underlineColor.xlsx         |binary
 sc/qa/unit/subsequent_export-test.cxx            |   18 +++++++++----
 4 files changed, 32 insertions(+), 17 deletions(-)

New commits:
commit edf5dcda53e9af586e9f9f28d29bd0c3c778b474
Author: Bartosz Kosiorek <gan...@poczta.onet.pl>
Date:   Wed May 24 01:13:26 2017 +0200

    tdf#104219 Don't export color information when color is automatic
    
    In LibreOffice and MS Office, there are two types of colors:
     - Automatic (which is taken from settings) and Fixed (which is set by RGB 
value).
    OOXML is setting automatic color by default, by not providing any RGB color.
    To preserve automatic color we need to not export
    RGB color during OOXML export.
    
    Change-Id: I8895230c4fffc9d8741f3eff37e64c4823d71da8
    Reviewed-on: https://gerrit.libreoffice.org/37970
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>
    Reviewed-on: https://gerrit.libreoffice.org/38276
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index d45e59ddc9c7..71046841c60c 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -152,6 +152,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
         rPropMap.setProperty( PROP_CharUnderlineHasColor, true);
         rPropMap.setProperty( PROP_CharUnderlineColor, 
maUnderlineColor.getColor( rFilter.getGraphicHelper() ));
     }
+    // TODO If bUnderlineFillFollowText uFillTx 
(CT_TextUnderlineFillFollowText) is set, fill color of the underline should be 
the same color as the text
 }
 
 void pushToGrabBag( PropertySet& rPropSet, const std::vector<PropertyValue>& 
aVectorOfProperyValues )
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index d9bc62d5f8f0..c8d148aeb1c2 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1398,24 +1398,30 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
         sal_uInt32 color = *o3tl::doAccess<sal_uInt32>(mAny);
         SAL_INFO("oox.shape", "run color: " << color << " auto: " << COL_AUTO);
 
-        if( color == COL_AUTO )  // nCharColor depends to the background color
+        // tdf#104219 In LibreOffice and MS Office, there are two types of 
colors:
+        // Automatic and Fixed. OOXML is setting automatic color, by not 
providing color.
+        if( color != COL_AUTO )
         {
-            color = mbIsBackgroundDark ? 0xffffff : 0x000000;
+            color &= 0xffffff;
+            // TODO: special handle embossed/engraved
+            WriteSolidFill( color );
         }
-        color &= 0xffffff;
-
-        // TODO: special handle embossed/engraved
-
-        WriteSolidFill( color );
     }
 
-    if( CGETAD( CharUnderlineColor ) )
+    if( ( underline != nullptr ) && CGETAD( CharUnderlineColor ) )
     {
         sal_uInt32 color = *o3tl::doAccess<sal_uInt32>(mAny);
-
-        mpFS->startElementNS( XML_a, XML_uFill,FSEND);
-        WriteSolidFill( color );
-        mpFS->endElementNS( XML_a, XML_uFill );
+        // if color is automatic, then we shouldn't write information about 
color but to take color from character
+        if( color != COL_AUTO )
+        {
+            mpFS->startElementNS( XML_a, XML_uFill, FSEND);
+            WriteSolidFill( color );
+            mpFS->endElementNS( XML_a, XML_uFill );
+        }
+        else
+        {
+            mpFS->singleElementNS( XML_a, XML_uFillTx, FSEND );
+        }
     }
 
     if( GETA( CharFontName ) )
diff --git a/sc/qa/unit/data/xlsx/underlineColor.xlsx 
b/sc/qa/unit/data/xlsx/underlineColor.xlsx
index 30346ce733db..124391b3bc11 100644
Binary files a/sc/qa/unit/data/xlsx/underlineColor.xlsx and 
b/sc/qa/unit/data/xlsx/underlineColor.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index e6e1e87f710b..9deb04ba8be0 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3428,16 +3428,24 @@ void ScExportTest::testSheetCondensedCharacterSpace()
 
 void ScExportTest::testTextUnderlineColor()
 {
-
     ScDocShellRef xDocSh = loadDoc("underlineColor.", FORMAT_XLSX);
     CPPUNIT_ASSERT(xDocSh.Is());
 
     xmlDocPtr pDoc = XPathHelper::parseExport(*xDocSh, m_xSFactory, 
"xl/drawings/drawing1.xml", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
-    OUString color = getXPath(pDoc,
-            
"/xdr:wsDr/xdr:twoCellAnchor/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr/a:uFill/a:solidFill/a:srgbClr",
 "val");
-    // make sure that the underline color is RED
-    CPPUNIT_ASSERT_EQUAL(OUString("ff0000"), color);
+    // Make sure the underline type is double line
+    assertXPath(pDoc, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr", "u", 
"dbl");
+
+    assertXPath(pDoc, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr", "b", 
"1");
+    // Make sure that the underline color is RED
+    assertXPath(pDoc, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr/a:uFill/a:solidFill/a:srgbClr",
 "val", "ff0000");
+
+    // Make sure the underline type is drawn with heavy line
+    assertXPath(pDoc, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr", "u", 
"heavy");
+    // tdf#104219 Make sure that uFill is not existing and uFillTx is set.
+    // It mean that color is automatic, should be the same color as the text.
+    assertXPath(pDoc, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr/a:uFill",
 0);
+    assertXPath(pDoc, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:sp[1]/xdr:txBody/a:p[1]/a:r[1]/a:rPr/a:uFillTx",
 1);
 }
 
 void ScExportTest::testSheetRunParagraphProperty()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to