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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 14 06:07:11 UTC 2018


 include/oox/export/drawingml.hxx                          |    6 ++
 oox/source/export/chartexport.cxx                         |    2 
 oox/source/export/drawingml.cxx                           |   32 +++++++++++++-
 sw/qa/extras/ooxmlexport/data/Chart_BorderLine_Style.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx                |   15 ++++++
 5 files changed, 52 insertions(+), 3 deletions(-)

New commits:
commit 761308edb65a6cf44ef84cebc387e77af8b70f83
Author:     Adam Kovacs <christo161 at gmail.com>
AuthorDate: Thu Sep 13 04:04:41 2018 -0400
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Sep 14 08:06:39 2018 +0200

    tdf#108064 OOXML export: fixing linestyle export in charts
    
    getLineDash function copy paste from ChartLinePanel.cxx.
    We query the actual linedash value associated to the LineDashName
    of the chart line via DashTable service.
    Thanks for the guidance of László Németh!
    
    Change-Id: I565fc968ce009803f9872da1f01dd56cfe07ddb3
    Reviewed-on: https://gerrit.libreoffice.org/60424
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 449e77da78e1..393752f78df6 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -81,6 +81,9 @@ namespace io {
 namespace uno {
     class XInterface;
 }
+namespace frame {
+    class XModel;
+}
 }}}
 
 struct EscherConnectorListEntry;
@@ -200,7 +203,8 @@ public:
     void WriteSrcRectXGraphic(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
                               css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
 
-    void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
+    void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
+                              css::uno::Reference< css::frame::XModel> const & xModel = nullptr );
 
     void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
                               css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 97adab7f5b00..584774d9bbbc 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2323,7 +2323,7 @@ void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet )
             FSEND );
 
     exportFill( xPropSet );
-    WriteOutline( xPropSet );
+    WriteOutline( xPropSet, getModel() );
 
     pFS->endElement( FSNS( XML_c, XML_spPr ) );
 }
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8e554ad671bd..ee6a43b58df5 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -134,6 +134,25 @@ namespace drawingml {
 #define CGETAD(propName) \
     (( bCheckDirect && GetPropertyAndState( rXPropSet, rXPropState, #propName, eState ) && eState == beans::PropertyState_DIRECT_VALUE )||GetProperty( rXPropSet, #propName ))
 
+css::uno::Any getLineDash( const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rDashName )
+    {
+        css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
+        css::uno::Reference<css::container::XNameAccess> xNameAccess(
+            xFact->createInstance("com.sun.star.drawing.DashTable"),
+            css::uno::UNO_QUERY );
+        if(xNameAccess.is())
+        {
+            if (!xNameAccess->hasByName(rDashName))
+                return css::uno::Any();
+
+            return xNameAccess->getByName(rDashName);
+        }
+
+        return css::uno::Any();
+    }
+
+
+
 // not thread safe
 int DrawingML::mnImageCounter = 1;
 int DrawingML::mnWdpImageCounter = 1;
@@ -571,7 +590,7 @@ void DrawingML::WriteLineArrow( const Reference< XPropertySet >& rXPropSet, bool
     }
 }
 
-void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet )
+void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Reference< frame::XModel > const & xModel )
 {
     drawing::LineStyle aLineStyle( drawing::LineStyle_NONE );
 
@@ -642,6 +661,17 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet )
             if (GetProperty(rXPropSet, "LineDash"))
             {
                 aLineDash = mAny.get<drawing::LineDash>();
+                if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 0) {
+                    OUString aLineDashName;
+                    GET(aLineDashName, LineDashName);
+                    if (!aLineDashName.isEmpty()) {
+                        if (xModel) {
+                            css::uno::Any aAny;
+                            aAny = getLineDash(xModel, aLineDashName);
+                            aLineDash = aAny.get<drawing::LineDash>();
+                        }
+                    }
+                }
                 bDashSet = true;
                 if (aLineDash.Style == DashStyle_ROUND || aLineDash.Style == DashStyle_ROUNDRELATIVE)
                 {
diff --git a/sw/qa/extras/ooxmlexport/data/Chart_BorderLine_Style.docx b/sw/qa/extras/ooxmlexport/data/Chart_BorderLine_Style.docx
new file mode 100755
index 000000000000..0d3b74b77c42
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/Chart_BorderLine_Style.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 2ffaa7008ff3..35209c0cecc3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -689,6 +689,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf119188_list_margin_in_cell, "tdf119188_list_marg
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(494), getProperty<sal_Int32>(getParagraphOfText(3, xCell->getText()), "ParaBottomMargin"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testChart_BorderLine_Style, "Chart_BorderLine_Style.docx")
+{
+    /* DOCX containing Chart with BorderLine Style as Dash Type should get preserved
+     * inside an XML tag <a:prstDash> with value "dash", "sysDot, "lgDot", etc.
+     */
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart1.xml");
+    if (!pXmlDoc)
+        return;
+
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:spPr/a:ln/a:prstDash", "val", "sysDot");
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:spPr/a:ln/a:prstDash", "val", "sysDash");
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:spPr/a:ln/a:prstDash", "val", "dash");
+
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list