diff options
author | Adam Kovacs <christo161@gmail.com> | 2018-09-13 04:04:41 -0400 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2018-09-14 08:06:39 +0200 |
commit | 761308edb65a6cf44ef84cebc387e77af8b70f83 (patch) | |
tree | 1d9cbf1d5353cdd1f239e183fe6d3d6d58aa0403 | |
parent | 4464f851a34fb000673e54a3f7d6395682d53003 (diff) |
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@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | include/oox/export/drawingml.hxx | 6 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 2 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 32 | ||||
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/Chart_BorderLine_Style.docx | bin | 0 -> 25288 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 15 |
5 files changed, 52 insertions, 3 deletions
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 Binary files differnew file mode 100755 index 000000000000..0d3b74b77c42 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/Chart_BorderLine_Style.docx 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: */ |