[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - chart2/inc chart2/source sw/qa

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 31 09:29:13 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 d8a6757a46898a334a3e8bad8cb77dcd19482939
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Mar 18 15:22:08 2020 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue Mar 31 11:28:42 2020 +0200

    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>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91374
    Tested-by: Jenkins
    Reviewed-by: Balazs Varga <balazs.varga991 at gmail.com>

diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx
index 5ae3930ebd01..f3e22f3629db 100644
--- a/chart2/inc/ChartView.hxx
+++ b/chart2/inc/ChartView.hxx
@@ -183,7 +183,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 797ac7b46f11..44ca2853f503 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2012,7 +2012,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;
 
@@ -2024,11 +2024,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;
@@ -2042,6 +2037,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) )
@@ -2932,6 +2930,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) );
@@ -2954,13 +2957,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.reset(new SeriesPlotterContainer(m_aVCooSysList));
@@ -2987,16 +2990,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);
 
@@ -3053,7 +3057,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();
 
@@ -3063,19 +3067,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;
@@ -3084,13 +3088,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 58b98a602e1a..e7e79213ec91 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2593,6 +2593,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129173)
         pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[22]/text", "56");
 }
 
+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