[Libreoffice-commits] core.git: compilerplugins/clang oox/inc oox/source sw/qa

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 24 09:45:33 UTC 2020


 compilerplugins/clang/constantparam.booleans.results |    4 ---
 oox/inc/drawingml/chart/axisconverter.hxx            |    2 -
 oox/inc/drawingml/chart/objectformatter.hxx          |    5 ----
 oox/source/drawingml/chart/axisconverter.cxx         |   22 ++++++++++++-------
 oox/source/drawingml/chart/objectformatter.cxx       |   20 -----------------
 oox/source/drawingml/chart/plotareaconverter.cxx     |   22 +++++++++++++------
 sw/qa/extras/layout/data/xaxis-labelbreak.docx       |binary
 sw/qa/extras/layout/layout2.cxx                      |   17 ++++++++++++++
 8 files changed, 49 insertions(+), 43 deletions(-)

New commits:
commit 21620f9d2f50e66dffc45a5afb539edb8d54434c
Author:     Tünde Tóth <toth.tunde at nisz.hu>
AuthorDate: Mon Nov 23 15:05:24 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Nov 24 10:44:54 2020 +0100

    tdf#138194 Chart OOXML import: set text break to true
    
    of rotated category axis label, if the rotation is 90
    or 270 degree and the inner size of the chart is not fixed.
    
    Change-Id: I02e1fd940af8a277435aa46d4ad93a42b6723710
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106422
    Tested-by: Jenkins
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/compilerplugins/clang/constantparam.booleans.results b/compilerplugins/clang/constantparam.booleans.results
index bf25ffeb07a3..1a183059a193 100644
--- a/compilerplugins/clang/constantparam.booleans.results
+++ b/compilerplugins/clang/constantparam.booleans.results
@@ -1930,10 +1930,6 @@ o3tl/qa/cow_wrapper_clients.hxx:41
     void o3tltests::cow_wrapper_client1::cow_wrapper_client1(int)
     int nVal
     1
-oox/inc/drawingml/chart/objectformatter.hxx:146
-    _Bool oox::drawingml::chart::ObjectFormatter::getTextRotation(const class oox::drawingml::chart::ModelRef<class oox::drawingml::TextBody> &,int)
-    int nDefaultRotation
-    0
 oox/inc/drawingml/chart/typegroupconverter.hxx:153
     void oox::drawingml::chart::TypeGroupConverter::convertLineSmooth(class oox::PropertySet &,_Bool) const
     _Bool bOoxSmooth
diff --git a/oox/inc/drawingml/chart/axisconverter.hxx b/oox/inc/drawingml/chart/axisconverter.hxx
index 6cebc008c3fd..6efa3af6262e 100644
--- a/oox/inc/drawingml/chart/axisconverter.hxx
+++ b/oox/inc/drawingml/chart/axisconverter.hxx
@@ -60,7 +60,7 @@ public:
     void convertFromModel(
         const css::uno::Reference<css::chart2::XCoordinateSystem>& rxCoordSystem,
         RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis,
-        sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx );
+        sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx, bool bUseFixedInnerSize );
 };
 
 
diff --git a/oox/inc/drawingml/chart/objectformatter.hxx b/oox/inc/drawingml/chart/objectformatter.hxx
index 06cece4fe02c..9498f0484d50 100644
--- a/oox/inc/drawingml/chart/objectformatter.hxx
+++ b/oox/inc/drawingml/chart/objectformatter.hxx
@@ -142,11 +142,6 @@ public:
     /** Returns true, if the passed shape properties have automatic fill mode. */
     static bool         isAutomaticFill( const ModelRef< Shape >& rxShapeProp );
 
-    /** Returns true, if the X Axis label rotation is 0 degree. */
-    static bool         getTextRotation(
-                            const ModelRef< TextBody >& rxTextProp,
-                            sal_Int32 nDefaultRotation = 0 );
-
 private:
     std::shared_ptr< ObjectFormatterData > mxData;
 };
diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
index fa506e5a04dc..8f062d001eeb 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -137,9 +137,10 @@ AxisConverter::~AxisConverter()
 {
 }
 
-void AxisConverter::convertFromModel(
-    const Reference< XCoordinateSystem >& rxCoordSystem,
-    RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx )
+void AxisConverter::convertFromModel(const Reference<XCoordinateSystem>& rxCoordSystem,
+                                     RefVector<TypeGroupConverter>& rTypeGroups,
+                                     const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx,
+                                     sal_Int32 nAxisIdx, bool bUseFixedInnerSize)
 {
     if (rTypeGroups.empty())
         return;
@@ -269,10 +270,17 @@ void AxisConverter::convertFromModel(
                 }
                 else
                 {
-                    // do not overlap text unless all labels are visible
-                    aAxisProp.setProperty( PROP_TextOverlap, mrModel.mnTickLabelSkip == 1 );
-                    // do not break text into several lines unless the rotation is 0 degree
-                    aAxisProp.setProperty( PROP_TextBreak, ObjectFormatter::getTextRotation( mrModel.mxTextProp ) );
+                    aAxisProp.setProperty(PROP_TextOverlap, true);
+                    /* do not break text into several lines unless the rotation is 0 degree,
+                       or the rotation is 90 degree and the inner size of the chart is not fixed,
+                       or the rotation is 270 degree and the inner size of the chart is not fixed */
+                    bool bTextBreak = true;
+                    double fRotationAngle = 0.0;
+                    if (aAxisProp.getProperty(fRotationAngle, PROP_TextRotation)
+                        && fRotationAngle != 0.0)
+                        bTextBreak = !bUseFixedInnerSize
+                                     && (fRotationAngle == 90.0 || fRotationAngle == 270.0);
+                    aAxisProp.setProperty(PROP_TextBreak, bTextBreak);
                     // do not stagger labels in two lines
                     aAxisProp.setProperty( PROP_ArrangeOrder, cssc::ChartAxisArrangeOrderType_SIDE_BY_SIDE );
                     //! TODO #i58731# show n-th category
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index fd580742c97a..d3b274e1fa3d 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -1139,26 +1139,6 @@ bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp )
     return !rxShapeProp || !rxShapeProp->getFillProperties().moFillType.has();
 }
 
-bool ObjectFormatter::getTextRotation( const ModelRef< TextBody >& rxTextProp, sal_Int32 nDefaultRotation )
-{
-    if( rxTextProp.is() )
-    {
-        double fAnglevalue = static_cast< double >( rxTextProp->getTextProperties().moRotation.get( nDefaultRotation ) );
-        if( fAnglevalue < -5400000.0 || fAnglevalue > 5400000.0 || fAnglevalue == 0.0 )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-    else
-    {
-        return true;
-    }
-}
-
 } // namespace oox
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index 8a8a721a1fe9..80ea37c57d30 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -70,7 +70,8 @@ public:
                             const Reference< XDiagram >& rxDiagram,
                             View3DModel& rView3DModel,
                             sal_Int32 nAxesSetIdx,
-                            bool bSupportsVaryColorsByPoint );
+                            bool bSupportsVaryColorsByPoint,
+                            bool bUseFixedInnerSize );
 
     /** Returns the automatic chart title if the axes set contains only one series. */
     const OUString& getAutomaticTitle() const { return maAutoTitle; }
@@ -105,7 +106,8 @@ ModelRef< AxisModel > lclGetOrCreateAxis( const AxesSetModel::AxisMap& rFromAxes
 }
 
 void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
-        View3DModel& rView3DModel, sal_Int32 nAxesSetIdx, bool bSupportsVaryColorsByPoint )
+                                        View3DModel& rView3DModel, sal_Int32 nAxesSetIdx,
+                                        bool bSupportsVaryColorsByPoint, bool bUseFixedInnerSize)
 {
     // create type group converter objects for all type groups
     typedef RefVector< TypeGroupConverter > TypeGroupConvVector;
@@ -165,15 +167,18 @@ void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
             ModelRef< AxisModel > xYAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Y_AXIS, C_TOKEN( valAx ), bMSO2007Doc );
 
             AxisConverter aXAxisConv( *this, *xXAxis );
-            aXAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx, API_X_AXIS );
+            aXAxisConv.convertFromModel(xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx,
+                                        API_X_AXIS, bUseFixedInnerSize);
             AxisConverter aYAxisConv( *this, *xYAxis );
-            aYAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx, API_Y_AXIS );
+            aYAxisConv.convertFromModel(xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx,
+                                        API_Y_AXIS, bUseFixedInnerSize);
 
             if( rFirstTypeGroup.isDeep3dChart() )
             {
                 ModelRef< AxisModel > xZAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Z_AXIS, C_TOKEN( serAx ), bMSO2007Doc );
                 AxisConverter aZAxisConv( *this, *xZAxis );
-                aZAxisConv.convertFromModel( xCoordSystem, aTypeGroups, nullptr, nAxesSetIdx, API_Z_AXIS );
+                aZAxisConv.convertFromModel(xCoordSystem, aTypeGroups, nullptr, nAxesSetIdx,
+                                            API_Z_AXIS, bUseFixedInnerSize);
             }
 
             // convert all chart type groups, this converts all series data and formatting
@@ -420,10 +425,15 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel )
             && aAxesSets[0]->maAxes[ API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0;
     sal_Int32 nAxesSetIdx = nStartAxesSetIdx;
 
+    bool bUseFixedInnerSize = false;
+    if (mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout)
+        bUseFixedInnerSize = mrModel.mxLayout->mnTarget == XML_inner;
+
     for (auto const& axesSet : aAxesSets)
     {
         AxesSetConverter aAxesSetConv(*this, *axesSet);
-        aAxesSetConv.convertFromModel( xDiagram, rView3DModel, nAxesSetIdx, bSupportsVaryColorsByPoint );
+        aAxesSetConv.convertFromModel(xDiagram, rView3DModel, nAxesSetIdx,
+                                      bSupportsVaryColorsByPoint, bUseFixedInnerSize);
         if(nAxesSetIdx == nStartAxesSetIdx)
         {
             maAutoTitle = aAxesSetConv.getAutomaticTitle();
diff --git a/sw/qa/extras/layout/data/xaxis-labelbreak.docx b/sw/qa/extras/layout/data/xaxis-labelbreak.docx
new file mode 100644
index 000000000000..6f34a8919961
Binary files /dev/null and b/sw/qa/extras/layout/data/xaxis-labelbreak.docx differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index f5b42ee947ed..da43c0fa1e90 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -700,6 +700,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHorizontal_multilevel)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(7945, nYposition, 20);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194)
+{
+    SwDoc* pDoc = createDoc("xaxis-labelbreak.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;
+    xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 8
+    // - Actual  : 7
+    // i.e. the X axis label flowed out of chart area.
+    assertXPath(pXmlDoc, "//textarray", 8);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124796)
 {
     SwDoc* pDoc = createDoc("tdf124796.odt");


More information about the Libreoffice-commits mailing list