Kaydet (Commit) 18909d45 authored tarafından Dennis Francis's avatar Dennis Francis Kaydeden (comit) Tomaž Vajngerl

tdf#108921 : Enforce a minimum legend size for pivot charts...

...proportional to the chart size. This lets a default pivot
chart maintain its current size even when there are no data points
which may result from a pivot field filter operation.

Tried to add a test, but could not with a reasonable amount of
effort.

Some observations I made when tried to create a unit test:

1. If a new chart is created using uno api fresh from a pivot table,
   no legend is created irrespective of whether there is data or not.
2. Pivot charts with zero data points work fine with this patch, but
   on round trip the chart needs to be explicitly refreshed by
   clicking one of the pivot table's field selectors to make the chart
   show axis/labels etc.

Change-Id: I010ca9093ce94dc216ba06e9d7aedaa412e59401
Reviewed-on: https://gerrit.libreoffice.org/39620Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst c9f6bd6a
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment