diff options
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 6ded0aae091a..98925974aec6 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -267,10 +267,15 @@ awt::Size lcl_placeLegendEntries( const Reference< drawing::XShapes > & xTarget, const Reference< lang::XMultiServiceFactory > & xShapeFactory, const awt::Size& rRemainingSpace, - sal_Int32 nYStartPosition) + sal_Int32 nYStartPosition, + const awt::Size& rPageSize, + bool bIsPivotChart) { bool bIsCustomSize = (eExpansion == css::chart::ChartLegendExpansion_CUSTOM); awt::Size aResultingLegendSize(0,0); + // For Pivot charts set the *minimum* legend size as a function of page size. + if ( bIsPivotChart ) + aResultingLegendSize = awt::Size((rPageSize.Width * 13) / 80, (rPageSize.Height * 31) / 90); if( bIsCustomSize ) aResultingLegendSize = awt::Size(rRemainingSpace.Width, rRemainingSpace.Height + nYStartPosition); @@ -569,13 +574,13 @@ awt::Size lcl_placeLegendEntries( if( !bIsCustomSize ) { if( bSymbolsLeftSide ) - aResultingLegendSize.Width = nCurrentXPos + nXPadding; + aResultingLegendSize.Width = std::max( aResultingLegendSize.Width, nCurrentXPos + nXPadding ); else { sal_Int32 nLegendWidth = -(nCurrentXPos-nXPadding); - aResultingLegendSize.Width = nLegendWidth; + aResultingLegendSize.Width = std::max( aResultingLegendSize.Width, nLegendWidth ); } - aResultingLegendSize.Height = nMaxYPos + nYPadding; + aResultingLegendSize.Height = std::max( aResultingLegendSize.Height, nMaxYPos + nYPadding ); } if( !bSymbolsLeftSide ) @@ -947,7 +952,10 @@ void VLegend::createShapes( bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( xLegendProp, m_nDefaultWritingMode ); - if (!aViewEntries.empty()) + uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider( mrModel.getDataProvider(), uno::UNO_QUERY ); + bool bIsPivotChart = xPivotTableDataProvider.is(); + + if ( !aViewEntries.empty() || bIsPivotChart ) { // create buttons long nUsedButtonHeight = 0; @@ -966,7 +974,7 @@ void VLegend::createShapes( // place the legend entries aLegendSize = lcl_placeLegendEntries(aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize, aMaxSymbolExtent, aTextProperties, xLegendContainer, - m_xShapeFactory, aLegendSize, nUsedButtonHeight); + m_xShapeFactory, aLegendSize, nUsedButtonHeight, rPageSize, bIsPivotChart); uno::Reference<beans::XPropertySet> xModelPage(mrModel.getPageBackground()); |