summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-03-18 15:22:08 +0100
committerLászló Németh <nemeth@numbertext.org>2020-03-27 17:16:08 +0100
commit4d5053627e3e625e7b8c37c8785c0c9da31b7b6d (patch)
tree6806cab3ce2ded66fde503e103b654f62fcc45d4 /chart2
parent0900c57f17e16b65309f7c5932e15354e923dd4a (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>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/inc/ChartView.hxx2
-rw-r--r--chart2/source/view/main/ChartView.cxx38
2 files changed, 22 insertions, 18 deletions
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 266ff6b6a8f9..2be47c84e76e 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -182,7 +182,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 bcda427a6bdb..9900d5139af4 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2020,7 +2020,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;
@@ -2032,11 +2032,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;
@@ -2050,6 +2045,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) )
@@ -2940,6 +2938,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) );
@@ -2962,13 +2965,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 = std::make_shared<SeriesPlotterContainer>(m_aVCooSysList);
@@ -2995,16 +2998,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);
@@ -3061,7 +3065,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();
@@ -3071,19 +3075,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;
@@ -3092,13 +3096,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;