[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - chart2/source sw/qa
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 9 13:53:51 UTC 2020
chart2/source/view/axes/VCartesianAxis.cxx | 39 ++++++++++++++------
sw/qa/extras/layout/data/testTruncatedAxisLabel.odt |binary
sw/qa/extras/layout/layout.cxx | 24 ++++++++++++
3 files changed, 52 insertions(+), 11 deletions(-)
New commits:
commit 64b15237ab2355a18bb729adaaaa27bc31ad13da
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Mon Mar 2 13:55:35 2020 +0100
Commit: Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Thu Apr 9 15:53:16 2020 +0200
tdf#131060 tdf#117088 chart view: fix missing or truncated axis labels
if we have enough space under the horizontal X axis.
Note: allow truncation of vertical X axis labels only if they
are text labels and the position is NEAR_AXIS or OUTSIDE_START.
Regressions from commit 35d062f7879d5414334643cb90bff411726b2168
(tdf#116163: Limit label height in chart if needed)
and commit 26caf1bc59c81704f11225e3e431e412deb8c475
(tdf#114179: Custom size and position of the chart wall)
Change-Id: Idf86bc2b5482bb50a266cda57cc502621c2e08ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89829
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 7c300296dd727990455449b19b111b9fc49eadad)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90269
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index dce4de52783b..c5e839337226 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -75,28 +75,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)
@@ -127,6 +128,7 @@ static Reference< drawing::XShape > createSingleLabel(
, const AxisProperties& rAxisProperties
, const tNameSequence& rPropNames
, const tAnySequence& rPropValues
+ , const bool bIsHorizontalAxis
)
{
if(rLabel.isEmpty())
@@ -141,7 +143,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 );
@@ -704,6 +706,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())
@@ -733,7 +750,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;
}
@@ -848,7 +865,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;
@@ -1017,7 +1034,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;
diff --git a/sw/qa/extras/layout/data/testTruncatedAxisLabel.odt b/sw/qa/extras/layout/data/testTruncatedAxisLabel.odt
new file mode 100644
index 000000000000..f8eb74904102
Binary files /dev/null and b/sw/qa/extras/layout/data/testTruncatedAxisLabel.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 7a5238ee534a..768663a945cc 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2437,6 +2437,30 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122800)
// This failed, if the textarray length of the first axis label not 22.
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTruncatedAxisLabel)
+{
+ SwDoc* pDoc = createDoc("testTruncatedAxisLabel.odt");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // test the X axis label visibility
+ assertXPathContent(
+ pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[1]/text",
+ "Long axis label truncated 1");
+
+ // test the Y axis label visibility
+ assertXPathContent(
+ pXmlDoc,
+ "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[3]/text",
+ "-5.00");
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128996)
{
SwDoc* pDoc = createDoc("tdf128996.docx");
More information about the Libreoffice-commits
mailing list