diff options
-rw-r--r-- | chart2/inc/ChartView.hxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 38 | ||||
-rw-r--r-- | sw/qa/extras/layout/data/tdf129095.docx | bin | 0 -> 26028 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 16 |
4 files changed, 38 insertions, 18 deletions
diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 266ff6b6a8f9..2be47c84e76e 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -182,7 +182,7 @@ public: private: //methods void createShapes(); void createShapes2D( const css::awt::Size& rPageSize ); - bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize ); + bool createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize, bool bHasRelativeSize ); void getMetaFile( const css::uno::Reference< css::io::XOutputStream >& xOutStream , bool bUseHighContrast ); SdrPage* getSdrPage(); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index bcda427a6bdb..9900d5139af4 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2020,7 +2020,7 @@ double lcl_getPageLayoutDistancePercentage() } bool getAvailablePosAndSizeForDiagram( - CreateShapeParam2D& rParam, const awt::Size & rPageSize, const uno::Reference<XDiagram>& xDiagram ) + CreateShapeParam2D& rParam, const awt::Size & rPageSize, const uno::Reference< beans::XPropertySet >& xProp) { rParam.mbUseFixedInnerSize = false; @@ -2032,11 +2032,6 @@ bool getAvailablePosAndSizeForDiagram( rParam.maRemainingSpace.Y += nYDistance; rParam.maRemainingSpace.Height -= 2*nYDistance; - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) - return false; - - uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); - bool bPosSizeExcludeAxes = false; if( xProp.is() ) xProp->getPropertyValue( "PosSizeExcludeAxes" ) >>= bPosSizeExcludeAxes; @@ -2050,6 +2045,9 @@ bool getAvailablePosAndSizeForDiagram( rParam.mbUseFixedInnerSize = bPosSizeExcludeAxes; } + if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + return false; + //position: chart2::RelativePosition aRelativePosition; if( xProp.is() && (xProp->getPropertyValue( "RelativePosition" )>>=aRelativePosition) ) @@ -2940,6 +2938,11 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) //create the group shape for diagram and axes first to have title and legends on top of it uno::Reference< XDiagram > xDiagram( mrChartModel.getFirstDiagram() ); + uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); + bool bHasRelativeSize = false; + if( xProp.is() && xProp->getPropertyValue("RelativeSize").hasValue() ) + bHasRelativeSize = true; + OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ) );//todo: other index if more than one diagram is possible uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( pShapeFactory->createGroup2D(mxRootShape,aDiagramCID) ); @@ -2962,13 +2965,13 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) lcl_createTitle( TitleHelper::MAIN_TITLE, mxRootShape, m_xShapeFactory, mrChartModel, aParam.maRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy); - if (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0)) return; lcl_createTitle( TitleHelper::SUB_TITLE, mxRootShape, m_xShapeFactory, mrChartModel, aParam.maRemainingSpace, rPageSize, ALIGN_TOP, bAutoPositionDummy ); - if (aParam.maRemainingSpace.Width <= 0|| aParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0)) return; aParam.mpSeriesPlotterContainer = std::make_shared<SeriesPlotterContainer>(m_aVCooSysList); @@ -2995,16 +2998,17 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xShapeFactory, m_xCC, aParam.maRemainingSpace, rPageSize, mrChartModel, aParam.mpSeriesPlotterContainer->getLegendEntryProviderList(), lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); - if (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0) + + if (!bHasRelativeSize && (aParam.maRemainingSpace.Width <= 0 || aParam.maRemainingSpace.Height <= 0)) return; - if (!createAxisTitleShapes2D(aParam, rPageSize)) + if (!createAxisTitleShapes2D(aParam, rPageSize, bHasRelativeSize)) return; bool bDummy = false; bool bIsVertical = DiagramHelper::getVertical(xDiagram, bDummy, bDummy); - if (getAvailablePosAndSizeForDiagram(aParam, rPageSize, mrChartModel.getFirstDiagram())) + if (getAvailablePosAndSizeForDiagram(aParam, rPageSize, xProp)) { awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent(aParam, rPageSize); @@ -3061,7 +3065,7 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) } } -bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize ) +bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css::awt::Size& rPageSize, bool bHasRelativeSize ) { uno::Reference<XDiagram> xDiagram = mrChartModel.getFirstDiagram(); @@ -3071,19 +3075,19 @@ bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css:: if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) rParam.mpVTitleX = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, ALIGN_BOTTOM, rParam.mbAutoPosTitleX ); - if (rParam.maRemainingSpace.Width <= 0 ||rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) rParam.mpVTitleY = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, ALIGN_LEFT, rParam.mbAutoPosTitleY ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) rParam.mpVTitleZ = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, ALIGN_RIGHT, rParam.mbAutoPosTitleZ ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; bool bDummy = false; @@ -3092,13 +3096,13 @@ bool ChartView::createAxisTitleShapes2D( CreateShapeParam2D& rParam, const css:: if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension ) ) rParam.mpVTitleSecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, rParam.mbAutoPosSecondTitleX ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension ) ) rParam.mpVTitleSecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, mxRootShape, m_xShapeFactory, mrChartModel , rParam.maRemainingSpace, rPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, rParam.mbAutoPosSecondTitleY ); - if (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0) + if (!bHasRelativeSize && (rParam.maRemainingSpace.Width <= 0 || rParam.maRemainingSpace.Height <= 0)) return false; return true; diff --git a/sw/qa/extras/layout/data/tdf129095.docx b/sw/qa/extras/layout/data/tdf129095.docx Binary files differnew file mode 100644 index 000000000000..3647028fcab3 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf129095.docx diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index e57b72264ec4..b6295cab0ef5 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2658,6 +2658,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf130380) CPPUNIT_ASSERT_DOUBLES_EQUAL(6727, nY, 50); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129095) +{ + SwDoc* pDoc = createDoc("tdf129095.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; + xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // check the inner chart area 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, testTdf116925) { SwDoc* pDoc = createDoc("tdf116925.docx"); |