diff options
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 25 | ||||
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/layout/data/tdf125334.odt | bin | 0 -> 14362 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 20 |
4 files changed, 38 insertions, 9 deletions
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 234e1000140a..4fac1f83b72e 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -510,7 +510,7 @@ TickInfo* MaxLabelTickIter::nextInfo() } bool VCartesianAxis::isBreakOfLabelsAllowed( - const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ) const + const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis, bool bIsVerticalAxis) const { if( m_aTextLabels.getLength() > 100 ) return false; @@ -525,8 +525,10 @@ bool VCartesianAxis::isBreakOfLabelsAllowed( rAxisLabelProperties.fRotationAngleDegree == 90.0 || rAxisLabelProperties.fRotationAngleDegree == 270.0 ) ) return false; - //break only for horizontal axis - return bIsHorizontalAxis; + if ( !m_aAxisProperties.m_bSwapXAndY ) + return bIsHorizontalAxis; + else + return bIsVerticalAxis; } namespace{ @@ -702,7 +704,7 @@ bool VCartesianAxis::createTextShapes( const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis(); const bool bIsVerticalAxis = pTickFactory->isVerticalAxis(); - if (!isBreakOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis) && + if (!isBreakOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis) && !isAutoStaggeringOfLabelsAllowed(rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis) && !rAxisLabelProperties.isStaggered()) return createTextShapesSimple(xTarget, rTickIter, rAxisLabelProperties, pTickFactory); @@ -714,7 +716,7 @@ bool VCartesianAxis::createTextShapes( B2DVector aTextToTickDistance = pTickFactory->getDistanceAxisTickToText(m_aAxisProperties, true); sal_Int32 nLimitedSpaceForText = -1; - if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) ) + if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) ) { nLimitedSpaceForText = nScreenDistanceBetweenTicks; if( bIsStaggered ) @@ -742,6 +744,12 @@ bool VCartesianAxis::createTextShapes( nLimitedSpaceForText = -1; } } + + // recalculate the nLimitedSpaceForText in case of vertical category axis if the text break is true + if ( m_aAxisProperties.m_bSwapXAndY && bIsVerticalAxis && rAxisLabelProperties.fRotationAngleDegree == 0.0 ) + { + nLimitedSpaceForText = rAxisLabelProperties.m_aMaximumSpaceForLabels.X; + } } // Stores an array of text label strings in case of a normal @@ -750,8 +758,11 @@ bool VCartesianAxis::createTextShapes( if( m_bUseTextLabels && !m_aAxisProperties.m_bComplexCategories ) pCategories = &m_aTextLabels; - bool bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()); - + bool bLimitedHeight; + if( !m_aAxisProperties.m_bSwapXAndY ) + bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()); + else + bLimitedHeight = fabs(aTextToTickDistance.getX()) < fabs(aTextToTickDistance.getY()); //prepare properties for multipropertyset-interface of shape tNameSequence aPropNames; tAnySequence aPropValues; diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index df15e4896198..1c020bc4174c 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -150,7 +150,7 @@ private: //methods * @return true if we can break a single line label text into multiple * lines for better fitting, otherwise false. */ - bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis ) const; + bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis, bool bIsVerticalAxis ) const; ::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const; ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const; diff --git a/sw/qa/extras/layout/data/tdf125334.odt b/sw/qa/extras/layout/data/tdf125334.odt Binary files differnew file mode 100644 index 000000000000..70ea914aa48a --- /dev/null +++ b/sw/qa/extras/layout/data/tdf125334.odt diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 9c3650e7107b..93cd45e1f429 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2324,7 +2324,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf108021) pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='22']", 8); - // This failed, if the textarray length of the first axis label not 17. + // This failed, if the textarray length of the first axis label not 22. +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf125334) +{ + SwDoc* pDoc = createDoc("tdf125334.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); + + assertXPath( + pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='17']", + 4); + // This failed, if the textarray length of the category axis label not 17. } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122800) |