diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-01-03 23:27:16 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-27 21:07:29 +0100 |
commit | 46f1fbcea97f777d12efed580a8f04da154106a3 (patch) | |
tree | 03798a6c7d49f201f783a12ea345ce538f8a5774 /oox | |
parent | f884e99aea2bf53a8cdc51a8de97cdb4d829576f (diff) |
tdf#114173 Preserve size of chart legend during xlsx export
This is a combination of 2 commits.
tdf#114173 Preserve size of chart legend during xlsx export
During export chart into .xlsx file,
the information about size of legend was not saved.
Example of proper size:
<c:w val="0.41459448854442293"/>
<c:h val="0.23161616722845749"/>
another issue was hardcoded "layoutTarget" which
was always "inner":
<c:layoutTarget val="inner"/>
also properties regarding default text style was not preserved:
<c:txPr>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:pPr>
<a:defRPr sz="900" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">
<a:solidFill>
<a:schemeClr val="tx1">
<a:lumMod val="65000"/>
<a:lumOff val="35000"/>
</a:schemeClr>
</a:solidFill>
</a:defRPr>
</a:pPr>
<a:endParaRPr lang="pl-PL"/>
</a:p>
</c:txPr>
With this patch all these issues was resolved, and in case
of layoutTarget "outer", the field is not availble at all,
according to specification.
Change-Id: I2c9b7a112bdd911542b5273e660222d7fefa2d88
Reviewed-on: https://gerrit.libreoffice.org/47358
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 84392651d2731cce91c3b2e144bed4ac07e4ddf1)
crashtesting: multiple export failures
since...
commit 84392651d2731cce91c3b2e144bed4ac07e4ddf1
Date: Wed Jan 3 23:27:16 2018 +0100
tdf#114173 Preserve size of chart legend during xlsx export
Change-Id: Iebc936a0f490d6b707dfee0343732753f56728e7
Reviewed-on: https://gerrit.libreoffice.org/48147
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit fa68bed11c180ebb0d45fb7779d538098b2921ff)
Reviewed-on: https://gerrit.libreoffice.org/48153
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/48726
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/chartexport.cxx | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 2ffb03fa7ba4..2592c74fd2e6 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> +#include <com/sun/star/chart/XDiagramPositioning.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> @@ -893,7 +894,7 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC } // plot area - exportPlotArea( ); + exportPlotArea( xChartDoc ); // legend if( bHasLegend ) exportLegend( xChartDoc ); @@ -996,7 +997,6 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x uno::Any aRelativePos = xProp->getPropertyValue("RelativePosition"); if (aRelativePos.hasValue()) { - chart2::RelativePosition aPos = aRelativePos.get<chart2::RelativePosition>(); pFS->startElement(FSNS(XML_c, XML_layout), FSEND); pFS->startElement(FSNS(XML_c, XML_manualLayout), FSEND); @@ -1006,9 +1006,10 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x pFS->singleElement(FSNS(XML_c, XML_yMode), XML_val, "edge", FSEND); + chart2::RelativePosition aPos = aRelativePos.get<chart2::RelativePosition>(); - double x = aPos.Primary; - double y = aPos.Secondary; + const double x = aPos.Primary; + const double y = aPos.Secondary; pFS->singleElement(FSNS(XML_c, XML_x), XML_val, IS(x), @@ -1016,6 +1017,24 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x pFS->singleElement(FSNS(XML_c, XML_y), XML_val, IS(y), FSEND); + + uno::Any aRelativeSize = xProp->getPropertyValue("RelativeSize"); + if (aRelativeSize.hasValue()) + { + chart2::RelativeSize aSize = aRelativeSize.get<chart2::RelativeSize>(); + + const double w = aSize.Primary; + const double h = aSize.Secondary; + + pFS->singleElement(FSNS(XML_c, XML_w), + XML_val, IS(w), + FSEND); + + pFS->singleElement(FSNS(XML_c, XML_h), + XML_val, IS(h), + FSEND); + } + SAL_WARN_IF(aPos.Anchor != css::drawing::Alignment_TOP_LEFT, "oox", "unsupported anchor position"); pFS->endElement(FSNS(XML_c, XML_manualLayout)); @@ -1031,6 +1050,9 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x // shape properties exportShapeProps( xProp ); + + // draw-chart:txPr text properties + exportTextProps( xProp ); } // legendEntry @@ -1155,7 +1177,7 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape ) pFS->endElement( FSNS( XML_c, XML_title ) ); } -void ChartExport::exportPlotArea( ) +void ChartExport::exportPlotArea( const Reference< css::chart::XChartDocument >& xChartDoc ) { Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( mxNewDiagram, uno::UNO_QUERY ); if( ! xBCooSysCnt.is()) @@ -1176,7 +1198,8 @@ void ChartExport::exportPlotArea( ) chart2::RelativePosition aPos = aAny.get<chart2::RelativePosition>(); aAny = xWall->getPropertyValue("RelativeSize"); chart2::RelativeSize aSize = aAny.get<chart2::RelativeSize>(); - exportManualLayout(aPos, aSize); + uno::Reference< css::chart::XDiagramPositioning > xDiagramPositioning( xChartDoc->getDiagram(), uno::UNO_QUERY ); + exportManualLayout(aPos, aSize, xDiagramPositioning->isExcludingDiagramPositioning() ); } } @@ -1288,14 +1311,21 @@ void ChartExport::exportPlotArea( ) } -void ChartExport::exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize) +void ChartExport::exportManualLayout(const css::chart2::RelativePosition& rPos, + const css::chart2::RelativeSize& rSize, + const bool bIsExcludingDiagramPositioning) { FSHelperPtr pFS = GetFS(); pFS->startElement(FSNS(XML_c, XML_layout), FSEND); pFS->startElement(FSNS(XML_c, XML_manualLayout), FSEND); - pFS->singleElement(FSNS(XML_c, XML_layoutTarget), - XML_val, "inner", - FSEND); + + // By default layoutTarget is set to "outer" and we shouldn't save it in that case + if ( bIsExcludingDiagramPositioning ) + { + pFS->singleElement(FSNS(XML_c, XML_layoutTarget), + XML_val, "inner", + FSEND); + } pFS->singleElement(FSNS(XML_c, XML_xMode), XML_val, "edge", FSEND); @@ -1305,8 +1335,8 @@ void ChartExport::exportManualLayout(const css::chart2::RelativePosition& rPos, double x = rPos.Primary; double y = rPos.Secondary; - double w = rSize.Primary; - double h = rSize.Secondary; + const double w = rSize.Primary; + const double h = rSize.Secondary; switch (rPos.Anchor) { case drawing::Alignment_LEFT: @@ -2391,20 +2421,18 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet) { FSHelperPtr pFS = GetFS(); pFS->startElement(FSNS(XML_c, XML_txPr), FSEND); - - pFS->startElement(FSNS(XML_a, XML_bodyPr), FSEND); - pFS->endElement(FSNS(XML_a, XML_bodyPr)); + pFS->singleElement( FSNS( XML_a, XML_bodyPr ), FSEND ); + pFS->singleElement( FSNS( XML_a, XML_lstStyle ), FSEND ); pFS->startElement(FSNS(XML_a, XML_p), FSEND); pFS->startElement(FSNS(XML_a, XML_pPr), FSEND); - bool bDummy = false; - sal_Int32 nDummy; - WriteRunProperties(xPropSet, false, XML_defRPr, true, bDummy, nDummy); + bool bOverrideCharHeight = false; + sal_Int32 nCharHeight; + WriteRunProperties(xPropSet, false, XML_defRPr, true, bOverrideCharHeight, nCharHeight); pFS->endElement(FSNS(XML_a, XML_pPr)); pFS->endElement(FSNS(XML_a, XML_p)); - pFS->endElement(FSNS(XML_c, XML_txPr)); } |