summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx39
1 files changed, 28 insertions, 11 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index dc619d91ff66..594277b953f8 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -77,28 +77,29 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape >
const AxisLabelProperties& rAxisLabelProperties,
const OUString& rLabel,
const tNameSequence& rPropNames,
- const tAnySequence& rPropValues )
+ const tAnySequence& rPropValues,
+ const bool bIsHorizontalAxis )
{
uno::Reference< text::XTextRange > xTextRange( xShape2DText, uno::UNO_QUERY );
if( !xTextRange.is() )
return;
- const sal_Int32 nFullHeight = rAxisLabelProperties.m_aFontReferenceSize.Height;
+ const sal_Int32 nFullSize = bIsHorizontalAxis ? rAxisLabelProperties.m_aFontReferenceSize.Height : rAxisLabelProperties.m_aFontReferenceSize.Width;
- if( !nFullHeight || !rLabel.getLength() )
+ if( !nFullSize || !rLabel.getLength() )
return;
- sal_Int32 nMaxLabelsHeight = nFullHeight - rAxisLabelProperties.m_aMaximumSpaceForLabels.Height - rAxisLabelProperties.m_aMaximumSpaceForLabels.Y;
+ sal_Int32 nMaxLabelsSize = bIsHorizontalAxis ? rAxisLabelProperties.m_aMaximumSpaceForLabels.Height : rAxisLabelProperties.m_aMaximumSpaceForLabels.Width;
const sal_Int32 nAvgCharWidth = xShape2DText->getSize().Width / rLabel.getLength();
- const sal_Int32 nTextSize = ShapeFactory::getSizeAfterRotation( xShape2DText,
- rAxisLabelProperties.fRotationAngleDegree ).Height;
+ const sal_Int32 nTextSize = bIsHorizontalAxis ? ShapeFactory::getSizeAfterRotation(xShape2DText, rAxisLabelProperties.fRotationAngleDegree).Height :
+ ShapeFactory::getSizeAfterRotation(xShape2DText, rAxisLabelProperties.fRotationAngleDegree).Width;
if( !nAvgCharWidth )
return;
const OUString sDots = "...";
- const sal_Int32 nCharsToRemove = ( nTextSize - nMaxLabelsHeight ) / nAvgCharWidth + 1;
+ const sal_Int32 nCharsToRemove = ( nTextSize - nMaxLabelsSize ) / nAvgCharWidth + 1;
sal_Int32 nNewLen = rLabel.getLength() - nCharsToRemove - sDots.getLength();
// Prevent from showing only dots
if (nNewLen < 0)
@@ -129,6 +130,7 @@ static Reference< drawing::XShape > createSingleLabel(
, const AxisProperties& rAxisProperties
, const tNameSequence& rPropNames
, const tAnySequence& rPropValues
+ , const bool bIsHorizontalAxis
)
{
if(rLabel.isEmpty())
@@ -143,7 +145,7 @@ static Reference< drawing::XShape > createSingleLabel(
->createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation );
if( rAxisProperties.m_bLimitSpaceForLabels )
- lcl_ResizeTextShapeToFitAvailableSpace(xShape2DText, rAxisLabelProperties, aLabel, rPropNames, rPropValues);
+ lcl_ResizeTextShapeToFitAvailableSpace(xShape2DText, rAxisLabelProperties, aLabel, rPropNames, rPropValues, bIsHorizontalAxis);
LabelPositionHelper::correctPositionForRotation( xShape2DText
, rAxisProperties.maLabelAlignment.meAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories );
@@ -709,6 +711,21 @@ bool VCartesianAxis::createTextShapes(
const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis();
const bool bIsVerticalAxis = pTickFactory->isVerticalAxis();
+ if( m_bUseTextLabels && (m_aAxisProperties.m_eLabelPos == css::chart::ChartAxisLabelPosition_NEAR_AXIS ||
+ m_aAxisProperties.m_eLabelPos == css::chart::ChartAxisLabelPosition_OUTSIDE_START))
+ {
+ if (bIsHorizontalAxis)
+ {
+ rAxisLabelProperties.m_aMaximumSpaceForLabels.Y = pTickFactory->getXaxisStartPos().getY();
+ rAxisLabelProperties.m_aMaximumSpaceForLabels.Height = rAxisLabelProperties.m_aFontReferenceSize.Height - rAxisLabelProperties.m_aMaximumSpaceForLabels.Y;
+ }
+ else if (bIsVerticalAxis)
+ {
+ rAxisLabelProperties.m_aMaximumSpaceForLabels.X = 0;
+ rAxisLabelProperties.m_aMaximumSpaceForLabels.Width = pTickFactory->getXaxisStartPos().getX();
+ }
+ }
+
if (!isBreakOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis) &&
!isAutoStaggeringOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis) &&
!rAxisLabelProperties.isStaggered())
@@ -738,7 +755,7 @@ bool VCartesianAxis::createTextShapes(
// recalculate the nLimitedSpaceForText in case of 90 and 270 degree if the text break is true
if ( rAxisLabelProperties.fRotationAngleDegree == 90.0 || rAxisLabelProperties.fRotationAngleDegree == 270.0 )
{
- nLimitedSpaceForText = rAxisLabelProperties.m_aFontReferenceSize.Height - pTickFactory->getXaxisStartPos().getY();
+ nLimitedSpaceForText = rAxisLabelProperties.m_aMaximumSpaceForLabels.Height;
m_aAxisProperties.m_bLimitSpaceForLabels = false;
}
@@ -853,7 +870,7 @@ bool VCartesianAxis::createTextShapes(
pTickInfo->xTextShape = createSingleLabel( m_xShapeFactory, xTarget
, aAnchorScreenPosition2D, aLabel
, rAxisLabelProperties, m_aAxisProperties
- , aPropNames, aPropValues );
+ , aPropNames, aPropValues, bIsHorizontalAxis );
if(!pTickInfo->xTextShape.is())
continue;
@@ -1022,7 +1039,7 @@ bool VCartesianAxis::createTextShapesSimple(
pTickInfo->xTextShape = createSingleLabel( m_xShapeFactory, xTarget
, aAnchorScreenPosition2D, aLabel
, rAxisLabelProperties, m_aAxisProperties
- , aPropNames, aPropValues );
+ , aPropNames, aPropValues, bIsHorizontalAxis );
if(!pTickInfo->xTextShape.is())
continue;