diff options
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 5 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 19 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.hxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/layout/data/tdf132956.docx | bin | 0 -> 25937 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 20 |
5 files changed, 38 insertions, 12 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 84961438c24a..bc9d7a18d1d3 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2233,12 +2233,13 @@ bool lcl_createLegend( const uno::Reference< XLegend > & xLegend if (!VLegend::isVisible(xLegend)) return false; + awt::Size rDefaultLegendSize; VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList, xPageShapes, xShapeFactory, rModel); aVLegend.setDefaultWritingMode( nDefaultWritingMode ); aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ), - rPageSize ); - aVLegend.changePosition( rRemainingSpace, rPageSize ); + rPageSize, rDefaultLegendSize ); + aVLegend.changePosition( rRemainingSpace, rPageSize, rDefaultLegendSize ); return true; } diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index facfe388fa42..669e575a18ac 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -271,7 +271,8 @@ awt::Size lcl_placeLegendEntries( const awt::Size& rRemainingSpace, sal_Int32 nYStartPosition, const awt::Size& rPageSize, - bool bIsPivotChart) + bool bIsPivotChart, + awt::Size& rDefaultLegendSize) { bool bIsCustomSize = (eExpansion == css::chart::ChartLegendExpansion_CUSTOM); awt::Size aResultingLegendSize(0,0); @@ -310,6 +311,9 @@ awt::Size lcl_placeLegendEntries( sal_Int32 nMaxEntryHeight = nYOffset + aMaxEntryExtent.Height; sal_Int32 nNumberOfEntries = rEntries.size(); + rDefaultLegendSize.Width = nMaxEntryWidth; + rDefaultLegendSize.Height = nMaxEntryHeight + nYPadding; + sal_Int32 nNumberOfColumns = 0, nNumberOfRows = 0; std::vector< sal_Int32 > aColumnWidths; std::vector< sal_Int32 > aRowHeights; @@ -870,7 +874,8 @@ bool VLegend::isVisible( const Reference< XLegend > & xLegend ) void VLegend::createShapes( const awt::Size & rAvailableSpace, - const awt::Size & rPageSize ) + const awt::Size & rPageSize, + awt::Size & rDefaultLegendSize ) { if(! (m_xLegend.is() && m_xShapeFactory.is() && @@ -980,7 +985,7 @@ void VLegend::createShapes( // place the legend entries aLegendSize = lcl_placeLegendEntries(aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize, aMaxSymbolExtent, aTextProperties, xLegendContainer, - m_xShapeFactory, aLegendSize, nUsedButtonHeight, rPageSize, bIsPivotChart); + m_xShapeFactory, aLegendSize, nUsedButtonHeight, rPageSize, bIsPivotChart, rDefaultLegendSize); uno::Reference<beans::XPropertySet> xModelPage(mrModel.getPageBackground()); @@ -1014,7 +1019,8 @@ void VLegend::createShapes( void VLegend::changePosition( awt::Rectangle & rOutAvailableSpace, - const awt::Size & rPageSize ) + const awt::Size & rPageSize, + const css::awt::Size & rDefaultLegendSize ) { if(! m_xShape.is()) return; @@ -1026,6 +1032,7 @@ void VLegend::changePosition( Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY_THROW ); chart2::RelativePosition aRelativePosition; + bool bDefaultLegendSize = rDefaultLegendSize.Width != 0 || rDefaultLegendSize.Height != 0; bool bAutoPosition = ! (xLegendProp->getPropertyValue( "RelativePosition") >>= aRelativePosition); @@ -1048,7 +1055,7 @@ void VLegend::changePosition( // manual position: relative to whole page awt::Rectangle aAvailableSpace( 0, 0, rPageSize.Width, rPageSize.Height ); awt::Point aPos = lcl_calculatePositionAndRemainingSpace( - aAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize, bOverlay ); + aAvailableSpace, rPageSize, aRelativePosition, ePos, bDefaultLegendSize ? rDefaultLegendSize : aLegendSize, bOverlay ); m_xShape->setPosition( aPos ); if (!bOverlay) @@ -1056,7 +1063,7 @@ void VLegend::changePosition( // calculate remaining space as if having autoposition: aRelativePosition = lcl_getDefaultPosition( ePos, rOutAvailableSpace, rPageSize ); lcl_calculatePositionAndRemainingSpace( - rOutAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize, bOverlay ); + rOutAvailableSpace, rPageSize, aRelativePosition, ePos, bDefaultLegendSize ? rDefaultLegendSize : aLegendSize, bOverlay ); } } } diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx index e5332c41fb48..297a99129d4d 100644 --- a/chart2/source/view/main/VLegend.hxx +++ b/chart2/source/view/main/VLegend.hxx @@ -50,7 +50,8 @@ public: void setDefaultWritingMode( sal_Int16 nDefaultWritingMode ); void createShapes( const css::awt::Size & rAvailableSpace, - const css::awt::Size & rPageSize ); + const css::awt::Size & rPageSize, + css::awt::Size & rDefaultLegendSize ); /** Sets the position according to its internal anchor. @@ -63,7 +64,8 @@ public: */ void changePosition( css::awt::Rectangle & rOutAvailableSpace, - const css::awt::Size & rReferenceSize ); + const css::awt::Size & rReferenceSize, + const css::awt::Size & rDefaultLegendSize ); static bool isVisible( const css::uno::Reference< css::chart2::XLegend > & xLegend ); diff --git a/sw/qa/extras/layout/data/tdf132956.docx b/sw/qa/extras/layout/data/tdf132956.docx Binary files differnew file mode 100644 index 000000000000..6e3852b38c5c --- /dev/null +++ b/sw/qa/extras/layout/data/tdf132956.docx diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index e98b7f0ebded..853d6b997381 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2369,7 +2369,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf115630) "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[2]", "x") .toInt32(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2886, nXRight - nXLeft, 2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2895, nXRight - nXLeft, 50); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf108021) @@ -2695,7 +2695,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129095) xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); - // check the inner chart area visibility with testing the X axis label + // check the inner chart area (relative size) visibility with testing the X axis label + assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray/text", + "Category 1"); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf132956) +{ + SwDoc* pDoc = createDoc("tdf132956.docx"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // check the inner chart area (default size) visibility with testing the X axis label assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray/text", "Category 1"); } |