diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2023-08-14 15:59:18 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-01-23 15:42:25 +0100 |
commit | 8c832149558632e4b7b2abd6d9a8a33a23103677 (patch) | |
tree | 395e931622dc6d15f03d5be99f41d81fe708dc15 /oox/source | |
parent | 70466aef8f07ac7b4c73687964f714c13aeab2c0 (diff) |
tdf#146487 Don't show generic diagram title when there is an empty title given
Bugdoc has autoTitleDeleted set to false (so title should be visible), but then an empty title is given.
In this case no default string should be added to the title, only in case of Pie Charts.
Any other Chart types show the default title in MS-Office.
Co-authored-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Change-Id: Ib445099a4a3d113cff6b1ffdfd093fe41c34716b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155681
Tested-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
(cherry picked from commit c205194b8c54011af4b2cd34fbc00f4885883643)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162270
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/drawingml/chart/chartspaceconverter.cxx | 14 | ||||
-rw-r--r-- | oox/source/drawingml/chart/plotareaconverter.cxx | 10 | ||||
-rw-r--r-- | oox/source/drawingml/chart/typegroupconverter.cxx | 9 |
3 files changed, 31 insertions, 2 deletions
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx index c83ed37e9c02..f9b370e04d8f 100644 --- a/oox/source/drawingml/chart/chartspaceconverter.cxx +++ b/oox/source/drawingml/chart/chartspaceconverter.cxx @@ -38,6 +38,7 @@ #include <drawingml/chart/titleconverter.hxx> #include <ooxresid.hxx> #include <strings.hrc> +#include <drawingml/textbody.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -183,7 +184,18 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern OUString aAutoTitle = aPlotAreaConv.getAutomaticTitle(); if( mrModel.mxTitle.is() || !aAutoTitle.isEmpty() ) { - if( aAutoTitle.isEmpty() ) + // tdf#146487 In some cases, we need to show the empty title + bool bShowEmptyTitle = aAutoTitle.isEmpty() && !mrModel.mbAutoTitleDel + && aPlotAreaConv.isSingleSeriesTitle() + && mrModel.mxTitle->mxShapeProp.is() + && mrModel.mxTitle->mxTextProp.is() + && mrModel.mxTitle->mxTextProp->isEmpty(); + // Also for tdf#146487 + bool bEmptyRichText = mrModel.mxTitle->mxText.is() + && mrModel.mxTitle->mxText->mxTextBody.is() + && mrModel.mxTitle->mxText->mxTextBody->isEmpty(); + + if (aAutoTitle.isEmpty() && !bShowEmptyTitle && !bEmptyRichText) aAutoTitle = OoxResId(STR_DIAGRAM_TITLE); Reference< XTitled > xTitled( getChartDocument(), UNO_QUERY_THROW ); TitleConverter aTitleConv( *this, mrModel.mxTitle.getOrCreate() ); diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx index 96e51c577d43..32e4de7d1ee4 100644 --- a/oox/source/drawingml/chart/plotareaconverter.cxx +++ b/oox/source/drawingml/chart/plotareaconverter.cxx @@ -76,6 +76,8 @@ public: /** Returns the automatic chart title if the axes set contains only one series. */ const OUString& getAutomaticTitle() const { return maAutoTitle; } + /** Returns true, if the chart contains only one series and have title textbox (even empty). */ + bool isSingleSeriesTitle() const { return mbSingleSeriesTitle; } /** Returns true, if the chart is three-dimensional. */ bool is3dChart() const { return mb3dChart; } /** Returns true, if chart type supports wall and floor format in 3D mode. */ @@ -88,13 +90,15 @@ private: bool mb3dChart; bool mbWall3dChart; bool mbPieChart; + bool mbSingleSeriesTitle; }; AxesSetConverter::AxesSetConverter( const ConverterRoot& rParent, AxesSetModel& rModel ) : ConverterBase< AxesSetModel >( rParent, rModel ), mb3dChart( false ), mbWall3dChart( false ), - mbPieChart( false ) + mbPieChart( false ), + mbSingleSeriesTitle( false ) { } @@ -127,7 +131,10 @@ void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram, // get automatic chart title, if there is only one type group if( aTypeGroups.size() == 1 ) + { maAutoTitle = rFirstTypeGroup.getSingleSeriesTitle(); + mbSingleSeriesTitle = rFirstTypeGroup.isSingleSeriesTitle(); + } /* Create a coordinate system. For now, all type groups from all axes sets have to be inserted into one coordinate system. Later, chart2 should @@ -422,6 +429,7 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel ) if(nAxesSetIdx == nStartAxesSetIdx) { maAutoTitle = aAxesSetConv.getAutomaticTitle(); + mbSingleSeriesTitle = aAxesSetConv.isSingleSeriesTitle(); mb3dChart = aAxesSetConv.is3dChart(); mbWall3dChart = aAxesSetConv.isWall3dChart(); mbPieChart = aAxesSetConv.isPieChart(); diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx index e8d8bb47bc33..327a855f708f 100644 --- a/oox/source/drawingml/chart/typegroupconverter.cxx +++ b/oox/source/drawingml/chart/typegroupconverter.cxx @@ -234,6 +234,15 @@ OUString TypeGroupConverter::getSingleSeriesTitle() const return aSeriesTitle; } +bool TypeGroupConverter::isSingleSeriesTitle() const +{ + if (!mrModel.maSeries.empty() && (maTypeInfo.mbSingleSeriesVis || (mrModel.maSeries.size() == 1)) && + mrModel.maSeries.front()->mxText.is()) + return true; + + return false; +} + Reference< XCoordinateSystem > TypeGroupConverter::createCoordinateSystem() { // create the coordinate system object |