[Libreoffice-commits] core.git: chart2/inc chart2/source sw/qa
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 27 16:16:48 UTC 2020
chart2/inc/ChartView.hxx | 2 -
chart2/source/view/main/ChartView.cxx | 38 +++++++++++++++++---------------
sw/qa/extras/layout/data/tdf129095.docx |binary
sw/qa/extras/layout/layout.cxx | 16 +++++++++++++
4 files changed, 38 insertions(+), 18 deletions(-)
New commits:
commit 4d5053627e3e625e7b8c37c8785c0c9da31b7b6d
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Mar 18 15:22:08 2020 +0100
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Fri Mar 27 17:16:08 2020 +0100
tdf#129095 Chart view: fix missing inner chart area
If the inner chart area has RelativeSize, always create
the plot area with that setting.
Regression from commit: 739ed2c29f49ea5e83bcd1352b2644c2e2d09f7b
(tdf#115630 tdf#88922 Chart: fix custom legend position and size)
Change-Id: I9265843c5d0d148c6a392e440b5d3b0c4ccf0e54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90708
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
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
new file mode 100644
index 000000000000..3647028fcab3
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf129095.docx differ
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");
More information about the Libreoffice-commits
mailing list