summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-05-12 15:36:06 +0200
committerMichael Meeks <michael.meeks@collabora.com>2020-07-10 17:13:23 +0200
commitba40ebde1042cbbe6abc8c66e497dcadf5fb30c0 (patch)
tree1398a6d162e485e7e30b29875b08a214ecf9330c /chart2
parent1a1b1504a5d5846049c7435e95ff5517f6b975de (diff)
tdf#132956 Chart view: fix missing plot area
Do not reduce the inside area of the chart depending on the size of the legend. Use the default legend size. Regression from commit: 739ed2c29f49ea5e83bcd1352b2644c2e2d09f7b (tdf#115630 tdf#88922 Chart: fix custom legend position and size) cherry picked from commit cf46500243c51071227e08c5067041e414180ebc Change-Id: Ic191229d7ceab1f2689ab07424353108f8cb2b95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94059 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: Tünde Tóth <tundeth@gmail.com> Reviewed-by: László Németh <nemeth@numbertext.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95583 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98507 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/main/ChartView.cxx5
-rw-r--r--chart2/source/view/main/VLegend.cxx19
-rw-r--r--chart2/source/view/main/VLegend.hxx6
3 files changed, 20 insertions, 10 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 44ca2853f503..f0f84a9783f2 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2252,12 +2252,13 @@ bool lcl_createLegend( const uno::Reference< XLegend > & xLegend
if (!VLegend::isVisible(xLegend))
return false;
+ awt::Size rDefaultLegendSize;
VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList,
xPageShapes, xShapeFactory, rModel);
aVLegend.setDefaultWritingMode( nDefaultWritingMode );
aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ),
- rPageSize );
- aVLegend.changePosition( rRemainingSpace, rPageSize );
+ rPageSize, rDefaultLegendSize );
+ aVLegend.changePosition( rRemainingSpace, rPageSize, rDefaultLegendSize );
return true;
}
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 8272696ea102..f9d836921ebe 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -270,7 +270,8 @@ awt::Size lcl_placeLegendEntries(
const awt::Size& rRemainingSpace,
sal_Int32 nYStartPosition,
const awt::Size& rPageSize,
- bool bIsPivotChart)
+ bool bIsPivotChart,
+ awt::Size& rDefaultLegendSize)
{
bool bIsCustomSize = (eExpansion == css::chart::ChartLegendExpansion_CUSTOM);
awt::Size aResultingLegendSize(0,0);
@@ -309,6 +310,9 @@ awt::Size lcl_placeLegendEntries(
sal_Int32 nMaxEntryHeight = nYOffset + aMaxEntryExtent.Height;
sal_Int32 nNumberOfEntries = rEntries.size();
+ rDefaultLegendSize.Width = nMaxEntryWidth;
+ rDefaultLegendSize.Height = nMaxEntryHeight + nYPadding;
+
sal_Int32 nNumberOfColumns = 0, nNumberOfRows = 0;
std::vector< sal_Int32 > aColumnWidths;
std::vector< sal_Int32 > aRowHeights;
@@ -870,7 +874,8 @@ bool VLegend::isVisible( const Reference< XLegend > & xLegend )
void VLegend::createShapes(
const awt::Size & rAvailableSpace,
- const awt::Size & rPageSize )
+ const awt::Size & rPageSize,
+ awt::Size & rDefaultLegendSize )
{
if(! (m_xLegend.is() &&
m_xShapeFactory.is() &&
@@ -980,7 +985,7 @@ void VLegend::createShapes(
// place the legend entries
aLegendSize = lcl_placeLegendEntries(aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize,
aMaxSymbolExtent, aTextProperties, xLegendContainer,
- m_xShapeFactory, aLegendSize, nUsedButtonHeight, rPageSize, bIsPivotChart);
+ m_xShapeFactory, aLegendSize, nUsedButtonHeight, rPageSize, bIsPivotChart, rDefaultLegendSize);
uno::Reference<beans::XPropertySet> xModelPage(mrModel.getPageBackground());
@@ -1014,7 +1019,8 @@ void VLegend::createShapes(
void VLegend::changePosition(
awt::Rectangle & rOutAvailableSpace,
- const awt::Size & rPageSize )
+ const awt::Size & rPageSize,
+ const css::awt::Size & rDefaultLegendSize )
{
if(! m_xShape.is())
return;
@@ -1026,6 +1032,7 @@ void VLegend::changePosition(
Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY_THROW );
chart2::RelativePosition aRelativePosition;
+ bool bDefaultLegendSize = rDefaultLegendSize.Width != 0 || rDefaultLegendSize.Height != 0;
bool bAutoPosition =
! (xLegendProp->getPropertyValue( "RelativePosition") >>= aRelativePosition);
@@ -1046,7 +1053,7 @@ void VLegend::changePosition(
// manual position: relative to whole page
awt::Rectangle aAvailableSpace( 0, 0, rPageSize.Width, rPageSize.Height );
awt::Point aPos = lcl_calculatePositionAndRemainingSpace(
- aAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize );
+ aAvailableSpace, rPageSize, aRelativePosition, ePos, bDefaultLegendSize ? rDefaultLegendSize : aLegendSize );
m_xShape->setPosition( aPos );
if( ePos != LegendPosition_CUSTOM )
@@ -1054,7 +1061,7 @@ void VLegend::changePosition(
// calculate remaining space as if having autoposition:
aRelativePosition = lcl_getDefaultPosition( ePos, rOutAvailableSpace, rPageSize );
lcl_calculatePositionAndRemainingSpace(
- rOutAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize );
+ rOutAvailableSpace, rPageSize, aRelativePosition, ePos, bDefaultLegendSize ? rDefaultLegendSize : aLegendSize );
}
}
}
diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx
index 9e58c40c601f..afc0b415cd10 100644
--- a/chart2/source/view/main/VLegend.hxx
+++ b/chart2/source/view/main/VLegend.hxx
@@ -50,7 +50,8 @@ public:
void setDefaultWritingMode( sal_Int16 nDefaultWritingMode );
void createShapes( const css::awt::Size & rAvailableSpace,
- const css::awt::Size & rPageSize );
+ const css::awt::Size & rPageSize,
+ css::awt::Size & rDefaultLegendSize );
/** Sets the position according to its internal anchor.
@@ -63,7 +64,8 @@ public:
*/
void changePosition(
css::awt::Rectangle & rOutAvailableSpace,
- const css::awt::Size & rReferenceSize );
+ const css::awt::Size & rReferenceSize,
+ const css::awt::Size & rDefaultLegendSize );
static bool isVisible(
const css::uno::Reference< css::chart2::XLegend > & xLegend );