chart2/qa/extras/chart2export.cxx                  |   11 +++++++++++
 chart2/qa/extras/data/ods/test_CrossBetween.ods    |binary
 chart2/source/model/template/ChartTypeTemplate.cxx |    7 +++++--
 chart2/source/tools/AxisHelper.cxx                 |    2 +-
 chart2/source/view/main/ChartView.cxx              |   17 +++++------------
 oox/source/drawingml/chart/axisconverter.cxx       |    2 --
 oox/source/export/chartexport.cxx                  |    2 +-
 7 files changed, 23 insertions(+), 18 deletions(-)

New commits:
commit 111c260ab2883b7906f1a66e222dbf4dc3c58c4f
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Thu Oct 3 20:31:44 2019 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Oct 7 12:36:28 2019 +0200

    tdf#127777 OOXML chart export: fix "CrossBetween" for not imported charts
    
    Newly created or ODF charts were still exported incorrectly, because
    ShiftedCategoryPosition was stored in the view code. Now it is removed
    to the model using ChartTypeTemplate::adaptScales.
    
    See also commit 6027ec08fd5df2e09e34ff61b3777ad2cc8304b3 'tdf#127777
    OOXML chart export: fix X axis position setting "CrossBetween"'
    
    Change-Id: I7cd69e311833bf9f24f3a600ee7c6312285a7738
    Reviewed-on: https://gerrit.libreoffice.org/80160
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 2589428831bc..8a0705f7d140 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -121,6 +121,7 @@ public:
     void testCombinedChartSecondaryAxisXLSX();
     void testCombinedChartSecondaryAxisODS();
     void testCrossBetweenXLSX();
+    void testCrossBetweenODS();
     void testAxisTitleRotationXLSX();
     void testAxisCrossBetweenXSLX();
     void testPieChartDataPointExplosionXLSX();
@@ -225,6 +226,7 @@ public:
     CPPUNIT_TEST(testCombinedChartSecondaryAxisXLSX);
     CPPUNIT_TEST(testCombinedChartSecondaryAxisODS);
     CPPUNIT_TEST(testCrossBetweenXLSX);
+    CPPUNIT_TEST(testCrossBetweenODS);
     CPPUNIT_TEST(testAxisTitleRotationXLSX);
     CPPUNIT_TEST(testAxisCrossBetweenXSLX);
     CPPUNIT_TEST(testPieChartDataPointExplosionXLSX);
@@ -1912,6 +1914,15 @@ void Chart2ExportTest::testCrossBetweenXLSX()
     assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
 }
 
+void Chart2ExportTest::testCrossBetweenODS()
+{
+    // Original file was created with LibreOffice
+    load("/chart2/qa/extras/data/ods/", "test_CrossBetween.ods");
+    xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
+    CPPUNIT_ASSERT(pXmlDoc);
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between");
+}
+
 void Chart2ExportTest::testAxisTitleRotationXLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
diff --git a/chart2/qa/extras/data/ods/test_CrossBetween.ods 
b/chart2/qa/extras/data/ods/test_CrossBetween.ods
new file mode 100644
index 000000000000..e59546b3d0cd
Binary files /dev/null and b/chart2/qa/extras/data/ods/test_CrossBetween.ods 
differ
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx 
b/chart2/source/model/template/ChartTypeTemplate.cxx
index c3710e45d7d4..c18851796ada 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -623,8 +623,11 @@ void ChartTypeTemplate::adaptScales(
                         aData.Categories = xCategories;
                         if(bSupportsCategories)
                         {
-
-                            Reference< XChartType > xChartType( 
getChartTypeForNewSeries(Sequence< Reference< XChartType > >() ));
+                            Reference< XChartType > 
xChartType(getChartTypeForNewSeries(Sequence< Reference< XChartType > >()));
+                            if( aData.AxisType == AxisType::CATEGORY )
+                            {
+                                aData.ShiftedCategoryPosition = 
::chart::ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault(xChartType);
+                            }
                             bool bSupportsDates = 
::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX );
                             if( aData.AxisType != AxisType::CATEGORY && ( 
aData.AxisType != AxisType::DATE || !bSupportsDates) )
                             {
diff --git a/chart2/source/tools/AxisHelper.cxx 
b/chart2/source/tools/AxisHelper.cxx
index 25d481bff352..6ec3d44f48d4 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -73,7 +73,7 @@ ScaleData AxisHelper::createDefaultScale()
     ScaleData aScaleData;
     aScaleData.AxisType = chart2::AxisType::REALNUMBER;
     aScaleData.AutoDateAxis = true;
-    aScaleData.ShiftedCategoryPosition = false;//this is adapted in the view 
code currently
+    aScaleData.ShiftedCategoryPosition = false;
     Sequence< SubIncrement > aSubIncrements(1);
     aSubIncrements[0] = SubIncrement();
     aScaleData.IncrementData.SubIncrements = aSubIncrements;
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 5fc24786e5ab..6824c4f516c9 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -324,8 +324,8 @@ public:
 
     void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel );
 
-    bool isCategoryPositionShifted(
-        const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, 
bool bShiftedCategoryPosition) const;
+    static bool isCategoryPositionShifted(
+        const chart2::ScaleData& rSourceScale, bool bHasComplexCategories );
 
 private:
     /** A vector of series plotters.
@@ -349,14 +349,12 @@ private:
      */
     sal_Int32 m_nMaxAxisIndex;
 
-    bool m_bChartTypeUsesShiftedCategoryPositionPerDefault;
     sal_Int32 m_nDefaultDateNumberFormat;
 };
 
 SeriesPlotterContainer::SeriesPlotterContainer( std::vector< 
std::unique_ptr<VCoordinateSystem> >& rVCooSysList )
         : m_rVCooSysList( rVCooSysList )
         , m_nMaxAxisIndex(0)
-        , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false)
         , m_nDefaultDateNumberFormat(0)
 {
 }
@@ -520,9 +518,6 @@ void 
SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
                 }
             }
 
-            if(nT==0)
-                m_bChartTypeUsesShiftedCategoryPositionPerDefault = 
ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( xChartType );
-
             bool bExcludingPositioning = 
DiagramHelper::getDiagramPositioningMode( xDiagram ) == 
DiagramPositioningMode_EXCLUDING;
             VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( 
xChartType, nDimensionCount, bExcludingPositioning );
             if( !pPlotter )
@@ -631,9 +626,9 @@ void 
SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
 }
 
 bool SeriesPlotterContainer::isCategoryPositionShifted(
-    const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, bool 
bShiftedCategoryPosition) const
+    const chart2::ScaleData& rSourceScale, bool bHasComplexCategories )
 {
-    if (rSourceScale.AxisType == AxisType::CATEGORY && 
(m_bChartTypeUsesShiftedCategoryPositionPerDefault || bShiftedCategoryPosition))
+    if (rSourceScale.AxisType == AxisType::CATEGORY && 
rSourceScale.ShiftedCategoryPosition)
         return true;
 
     if (rSourceScale.AxisType == AxisType::CATEGORY && bHasComplexCategories)
@@ -683,9 +678,7 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& 
rNullDate)
                         AxisHelper::checkDateAxis( aSourceScale, pCatProvider, 
bDateAxisAllowed );
 
                     bool bHasComplexCat = pCatProvider && 
pCatProvider->hasComplexCategories();
-                    // Come from CrossBetween OOXML tag
-                    bool bShiftedCategoryPosition = 
aSourceScale.ShiftedCategoryPosition;
-                    aSourceScale.ShiftedCategoryPosition = 
isCategoryPositionShifted(aSourceScale, bHasComplexCat, 
bShiftedCategoryPosition);
+                    aSourceScale.ShiftedCategoryPosition = 
isCategoryPositionShifted(aSourceScale, bHasComplexCat);
 
                     m_aAxisUsageList[xAxis].aAutoScaling = 
ScaleAutomatism(aSourceScale, rNullDate);
                 }
diff --git a/oox/source/drawingml/chart/axisconverter.cxx 
b/oox/source/drawingml/chart/axisconverter.cxx
index 0f6973b02ec4..9f2cc0f715dc 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -224,8 +224,6 @@ void AxisConverter::convertFromModel(
             case API_Y_AXIS:
                 OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( valAx ), 
"AxisConverter::convertFromModel - unexpected axis model type (must: c:valAx)" 
);
                 aScaleData.AxisType = isPercent(rTypeGroups) ? 
cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER;
-                if( mrModel.mnCrossBetween != -1 )
-                    aScaleData.ShiftedCategoryPosition = 
mrModel.mnCrossBetween == XML_between;
             break;
             case API_Z_AXIS:
                 OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( serAx ), 
"AxisConverter::convertFromModel - unexpected axis model type (must: c:serAx)" 
);
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index ee4d83766846..d51ab5191d33 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -251,7 +251,7 @@ static bool lcl_isCategoryAxisShifted(const Reference< 
chart2::XChartDocument >&
                     if( xAxis.is())
                     {
                         chart2::ScaleData aScaleData = xAxis->getScaleData();
-                        if( aScaleData.AxisType == AXIS_PRIMARY_Y )
+                        if( aScaleData.Categories.is() )
                         {
                             isCategoryPositionShifted = 
aScaleData.ShiftedCategoryPosition;
                             break;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to