[Libreoffice-commits] core.git: chart2/source sw/qa

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 2 07:31:19 UTC 2019


 chart2/source/inc/ChartTypeHelper.hxx   |    1 +
 chart2/source/tools/ChartTypeHelper.cxx |   11 +++++++++++
 chart2/source/view/main/ChartView.cxx   |    3 ++-
 sw/qa/extras/layout/data/tdf129054.docx |binary
 sw/qa/extras/layout/layout.cxx          |   26 ++++++++++++++++++++++++++
 5 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit ea97f0926e138712c3800f5274012f0f04fc1c47
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Nov 27 10:31:48 2019 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Dec 2 08:30:33 2019 +0100

    tdf#129054 Chart OOXML Import: Fix size of Pie Chart
    
    Do not shift (set to false ShiftedCategoryPosition)
    the category axis for Pie chart with complex category.
    
    Change-Id: I3b1d99899a2daf9fd7a596c88531797aa5084734
    Reviewed-on: https://gerrit.libreoffice.org/83871
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx
index c2945dfb9380..c570a15163bd 100644
--- a/chart2/source/inc/ChartTypeHelper.hxx
+++ b/chart2/source/inc/ChartTypeHelper.hxx
@@ -49,6 +49,7 @@ public:
     static bool shiftCategoryPosAtXAxisPerDefault(     const css::uno::Reference< css::chart2::XChartType >& xChartType );
     static bool isSupportingAxisPositioning(     const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex );
     static bool isSupportingDateAxis( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex );
+    static bool isSupportingComplexCategory( const css::uno::Reference< css::chart2::XChartType >& xChartType );
 
     //returns sequence of css::chart::DataLabelPlacement
     static css::uno::Sequence < sal_Int32 > getSupportedLabelPlacements(
diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx
index 78d841755374..92974f5c5585 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -419,6 +419,17 @@ bool ChartTypeHelper::isSupportingDateAxis( const uno::Reference< chart2::XChart
     return true;
 }
 
+bool ChartTypeHelper::isSupportingComplexCategory( const uno::Reference< chart2::XChartType >& xChartType )
+{
+    if( xChartType.is() )
+    {
+        OUString aChartTypeName = xChartType->getChartType();
+        if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
+            return false;
+    }
+    return true;
+}
+
 bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType )
 {
     if(xChartType.is())
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index ae2a3d7d0ae6..83385f4f5d22 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -652,6 +652,7 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate)
     {
         uno::Reference<XCoordinateSystem> xCooSys = pVCooSys->getModel();
         sal_Int32 nDimCount = xCooSys->getDimension();
+        bool bComplexCategoryAllowed = ChartTypeHelper::isSupportingComplexCategory(AxisHelper::getChartTypeByIndex(xCooSys, 0));
 
         for (sal_Int32 nDimIndex = 0; nDimIndex < nDimCount; ++nDimIndex)
         {
@@ -676,7 +677,7 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate)
                     if (nDimIndex == 0)
                         AxisHelper::checkDateAxis( aSourceScale, pCatProvider, bDateAxisAllowed );
 
-                    bool bHasComplexCat = pCatProvider && pCatProvider->hasComplexCategories();
+                    bool bHasComplexCat = pCatProvider && pCatProvider->hasComplexCategories() && bComplexCategoryAllowed;
                     aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat);
 
                     m_aAxisUsageList[xAxis].aAutoScaling = ScaleAutomatism(aSourceScale, rNullDate);
diff --git a/sw/qa/extras/layout/data/tdf129054.docx b/sw/qa/extras/layout/data/tdf129054.docx
new file mode 100644
index 000000000000..5d02d7e87a33
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf129054.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index d1517323b581..82febf907297 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2447,6 +2447,32 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124796)
         "15");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129054)
+{
+    SwDoc* pDoc = createDoc("tdf129054.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);
+
+    // Test the size of diameter of Pie chart.
+    sal_Int32 nYTop
+        = getXPath(pXmlDoc,
+                   "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[1]",
+                   "y")
+              .toInt32();
+    sal_Int32 nYBottom
+        = getXPath(
+              pXmlDoc,
+              "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[31]",
+              "y")
+              .toInt32();
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(4810), nYTop - nYBottom);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
 {
     SwDoc* pDoc = createDoc("tdf116925.docx");


More information about the Libreoffice-commits mailing list