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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 8 14:43:33 UTC 2019


 chart2/qa/extras/chart2import.cxx          |   20 ++++++++++++++++++++
 chart2/qa/extras/data/ods/tdf108021.ods    |binary
 chart2/source/view/axes/VCartesianAxis.cxx |   19 ++++++++++++++++++-
 sw/qa/extras/layout/data/tdf108021.odt     |binary
 sw/qa/extras/layout/layout.cxx             |   20 ++++++++++++++++++++
 5 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit 415dbafb2dcc5b9b897b5febaed66fc9431a6857
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Fri Dec 14 14:38:49 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Feb 8 15:43:09 2019 +0100

    tdf#108021 Chart: Fix text break of column chart X axis
    
    With this patch the text break is allowed for column chart
    X axis if the text is rotated with 0, 90 or 270 degree.
    Also recalculate the nLimitedSpaceForText in case of 90
    and 270 degree if the X axis label's text break is true.
    (cherry-picked from commit: f8d6de19181d749d7c2b345ce7084c0c07fa3eab)
    (cherry-picked from commit: 40ffaa4f23fe59f979222facf1688d25c60651b6)
    
    Change-Id: I5d78be6ed83dd195bbc34185d5f6b7e44f555d9b
    Reviewed-on: https://gerrit.libreoffice.org/66061
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index caf55b448b92..aa46fbae8503 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -69,6 +69,7 @@ public:
     void testTdf86624(); // manually placed legends
     void testTdf105517();
     void testTdf106217();
+    void testTdf108021();
     void testAutoBackgroundXLSX();
     void testChartAreaStyleBackgroundXLSX();
     void testChartHatchFillXLSX();
@@ -148,6 +149,7 @@ public:
     CPPUNIT_TEST(testTdf86624);
     CPPUNIT_TEST(testTdf105517);
     CPPUNIT_TEST(testTdf106217);
+    CPPUNIT_TEST(testTdf108021);
     CPPUNIT_TEST(testAutoBackgroundXLSX);
     CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX);
     CPPUNIT_TEST(testChartHatchFillXLSX);
@@ -847,6 +849,24 @@ void Chart2ImportTest::testTdf106217()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(2700), aSize.Height);
 }
 
+void Chart2ImportTest::testTdf108021()
+{
+    // Tdf108021 : To check TextBreak value is true.
+    load("/chart2/qa/extras/data/ods/", "tdf108021.ods");
+    uno::Reference< chart::XDiagram > mxDiagram;
+    uno::Reference< beans::XPropertySet > xAxisProp;
+    bool bTextBreak = false;
+    uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
+    mxDiagram.set(xChartDoc->getDiagram());
+    CPPUNIT_ASSERT(mxDiagram.is());
+    uno::Reference< chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY );
+    CPPUNIT_ASSERT(xAxisXSupp.is());
+    xAxisProp = xAxisXSupp->getXAxis();
+    xAxisProp->getPropertyValue("TextBreak") >>= bTextBreak;
+    // Expected value of 'TextBreak' is true
+    CPPUNIT_ASSERT(bTextBreak);
+}
+
 void Chart2ImportTest::testTransparentBackground(OUString const & filename)
 {
     load("/chart2/qa/extras/data/xlsx/", filename);
diff --git a/chart2/qa/extras/data/ods/tdf108021.ods b/chart2/qa/extras/data/ods/tdf108021.ods
new file mode 100755
index 000000000000..ebbc5e56f24f
Binary files /dev/null and b/chart2/qa/extras/data/ods/tdf108021.ods differ
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index 0b488abaa5e1..4db36271ce20 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -526,7 +526,9 @@ bool VCartesianAxis::isBreakOfLabelsAllowed(
     //no break for value axis
     if( !m_bUseTextLabels )
         return false;
-    if( rAxisLabelProperties.fRotationAngleDegree != 0.0 )
+    if( !( rAxisLabelProperties.fRotationAngleDegree == 0.0 ||
+           rAxisLabelProperties.fRotationAngleDegree == 90.0 ||
+           rAxisLabelProperties.fRotationAngleDegree == 270.0 ) )
         return false;
     //break only for horizontal axis
     return bIsHorizontalAxis;
@@ -730,6 +732,21 @@ bool VCartesianAxis::createTextShapes(
                 nReduce = 1;
             nLimitedSpaceForText -= nReduce;
         }
+
+        // recalculate the nLimitedSpaceForText in case of 90 and 270 degree if the text break is true
+        if ( rAxisLabelProperties.fRotationAngleDegree == 90.0 || rAxisLabelProperties.fRotationAngleDegree == 270.0 )
+        {
+            if ( rAxisLabelProperties.m_aFontReferenceSize.Height - rAxisLabelProperties.m_aMaximumSpaceForLabels.Height > 2 * rAxisLabelProperties.m_aMaximumSpaceForLabels.Y )
+            {
+                const sal_Int32 nFullHeight = rAxisLabelProperties.m_aFontReferenceSize.Height;
+                sal_Int32 nMaxLabelsHeight = nFullHeight - ( rAxisLabelProperties.m_aMaximumSpaceForLabels.Height + rAxisLabelProperties.m_aMaximumSpaceForLabels.Y );
+                nLimitedSpaceForText = nMaxLabelsHeight;
+            }
+            else
+            {
+                nLimitedSpaceForText = -1;
+            }
+        }
     }
 
      // Stores an array of text label strings in case of a normal
diff --git a/sw/qa/extras/layout/data/tdf108021.odt b/sw/qa/extras/layout/data/tdf108021.odt
new file mode 100755
index 000000000000..a81fe9c9a40d
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf108021.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index cd4b87def41d..1bff20b3a5cb 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -41,6 +41,7 @@ public:
     void testRedlineCharAttributes();
     void testTdf116830();
     void testTdf114163();
+    void testTdf108021();
     void testTdf116925();
     void testTdf117028();
     void testTdf106390();
@@ -77,6 +78,7 @@ public:
     CPPUNIT_TEST(testRedlineCharAttributes);
     CPPUNIT_TEST(testTdf116830);
     CPPUNIT_TEST(testTdf114163);
+    CPPUNIT_TEST(testTdf108021);
     CPPUNIT_TEST(testTdf116925);
     CPPUNIT_TEST(testTdf117028);
     CPPUNIT_TEST(testTdf106390);
@@ -2323,6 +2325,24 @@ void SwLayoutWriter::testTdf114163()
     // This failed, if the legend first label is not "Data3".
 }
 
+void SwLayoutWriter::testTdf108021()
+{
+    SwDoc* pDoc = createDoc("tdf108021.odt");
+    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 = dumper.dumpAndParse(*xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    assertXPath(
+        pXmlDoc,
+        "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/textarray[@length='22']",
+        8);
+    // This failed, if the textarray length of the first axis label not 22.
+}
+
 void SwLayoutWriter::testTdf116925()
 {
     SwDoc* pDoc = createDoc("tdf116925.docx");


More information about the Libreoffice-commits mailing list