diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-03-18 15:22:08 +0100 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2020-03-31 11:28:42 +0200 |
commit | d8a6757a46898a334a3e8bad8cb77dcd19482939 (patch) | |
tree | 801df155fa0f245819164a26a7f5df9388bfb940 /chart2 | |
parent | eb43950455a9b644bc06b17e2ce600be77d16343 (diff) |
tdf#129095 Chart view: fix missing inner chart area
If the inner chart area has RelativeSize, always create
the plot area with that setting.
Regression from commit: 739ed2c29f49ea5e83bcd1352b2644c2e2d09f7b
(tdf#115630 tdf#88922 Chart: fix custom legend position and size)
Change-Id: I9265843c5d0d148c6a392e440b5d3b0c4ccf0e54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90708
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91374
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga991@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/inc/ChartView.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 38 |
2 files changed, 22 insertions, 18 deletions
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 5ae3930ebd01..f3e22f3629db 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -183,7 +183,7 @@ public: private: //methods void createShapes(); void createShapes2D( const css::awt::Size& rPageSize ); - bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize ); + bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize, bool bHasRelativeSize ); void getMetaFile( const css::uno::Reference< css::io::XOutputStream >& xOutStream , bool bUseHighContrast ); SdrPage* getSdrPage(); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 797ac7b46f11..44ca2853f503 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2012,7 +2012,7 @@ double lcl_getPageLayoutDistancePercentage() } bool getAvailablePosAndSizeForDiagram( - CreateShapeParam2D& rParam, const awt::Size & rPageSize, const uno::Reference<XDiagram>& xDiagram ) + CreateShapeParam2D& rParam, const awt::Size & rPageSize, const uno::Reference< beans::XPropertySet >& xProp) { rParam.mbUseFixedInnerSize = false; @@ -2024,11 +2024,6 @@ bool getAvailablePosAndSizeForDiagram( rParam.maRemainingSpace.Y += nYDistance; rParam.maRemainingSpace.Height -= 2*nYDistance; - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) - return false; - - uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); - bool bPosSizeExcludeAxes = false; if( xProp.is() ) xProp->getPropertyValue( "PosSizeExcludeAxes" ) >>= bPosSizeExcludeAxes; @@ -2042,6 +2037,9 @@ bool getAvailablePosAndSizeForDiagram( rParam.mbUseFixedInnerSize = bPosSizeExcludeAxes; } + if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + return false; + //position: chart2::RelativePosition aRelativePosition; if( xProp.is() && (xProp->getPropertyValue( "RelativePosition" )>>=aRelativePosition) ) @@ -2932,6 +2930,11 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) //create the group shape for diagram and axes first to have title and legends on top of it uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); + uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); + bool bHasRelativeSize = false; + if( xProp.is() && xProp->getPropertyValue("RelativeSize").hasValue() ) + bHasRelativeSize = true; + OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ) );//todo: other index if more than one diagram is possible uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( pShapeFactory->createGroup2D(mxRootShape,aDiagramCID) ); @@ -2954,13 +2957,13 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) lcl_createTitle( TitleHelper::MAIN_TITLE, mxRootShape, m_xShapeFactory, mrChartModel, aParam.maRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy); - if (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0)) return; lcl_createTitle( TitleHelper::SUB_TITLE, mxRootShape, m_xShapeFactory, mrChartModel, aParam.maRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); - if (aParam.maRemainingSpace.Width <= 0|| aParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0)) return; aParam.mpSeriesPlotterContainer.reset(new SeriesPlotterContainer(m_aVCooSysList)); @@ -2987,16 +2990,17 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC, aParam.maRemainingSpace, rPageSize, mrChartModel, aParam.mpSeriesPlotterContainer->getLegendEntryProviderList(), lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); - if (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0) + + if (!bHasRelativeSize && (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0)) return; - if (!createAxisTitleShapes2D(aParam, rPageSize)) + if (!createAxisTitleShapes2D(aParam, rPageSize, bHasRelativeSize)) return; bool bDummy = false; bool bIsVertical = DiagramHelper::getVertical(xDiagram, bDummy, bDummy); - if (getAvailablePosAndSizeForDiagram(aParam, rPageSize, mrChartModel.getFirstDiagram())) + if (getAvailablePosAndSizeForDiagram(aParam, rPageSize, xProp)) { awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent(aParam, rPageSize); @@ -3053,7 +3057,7 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) } } -bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize ) +bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize, bool bHasRelativeSize ) { uno::Reference<XDiagram> xDiagram = mrChartModel.getFirstDiagram(); @@ -3063,19 +3067,19 @@ bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css:: if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) rParam.mpVTitleX = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, ALIGN_BOTTOM, rParam.mbAutoPosTitleX ); - if (rParam.maRemainingSpace.Width <= 0 ||rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) rParam.mpVTitleY = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, ALIGN_LEFT, rParam.mbAutoPosTitleY ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) rParam.mpVTitleZ = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, ALIGN_RIGHT, rParam.mbAutoPosTitleZ ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; bool bDummy = false; @@ -3084,13 +3088,13 @@ bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css:: if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension ) ) rParam.mpVTitleSecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, rParam.mbAutoPosSecondTitleX ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension ) ) rParam.mpVTitleSecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, rParam.mbAutoPosSecondTitleY ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; return true; |