summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-01-04 15:12:38 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-02-08 15:42:33 +0100
commit997a1ae35041dc8eba5ba7c4e7e3552632ea08d4 (patch)
tree4ac30db3352415f0b4d9512a4fed4db9b209fa48
parent49021f15cfb1dfb43dde73492df289f64a79297d (diff)
tdf#122091 OOXML Import: Automatically break of X Axis labels
Set the TextBreak value automatically true, only if the X axis labels rotation is 0 degree. The MS Office using a similar method because there is no any XML tag in the OOXML standard which refer to this setting. Change-Id: Ie84a95935f0d5c4c1f9a30803e22572141385960 Reviewed-on: https://gerrit.libreoffice.org/65853 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> (cherry picked from commit 015569fc919b702f7a1b0f09038bafa9f104ca70) Reviewed-on: https://gerrit.libreoffice.org/65934
-rw-r--r--chart2/qa/extras/chart2import.cxx21
-rwxr-xr-xchart2/qa/extras/data/xlsx/chart_label_text_break.xlsxbin0 -> 13940 bytes
-rw-r--r--oox/inc/drawingml/chart/objectformatter.hxx5
-rw-r--r--oox/source/drawingml/chart/axisconverter.cxx4
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx20
5 files changed, 48 insertions, 2 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index c85bcc67c06a..caf55b448b92 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -74,6 +74,7 @@ public:
void testChartHatchFillXLSX();
void testAxisTextRotationXLSX();
// void testTextCanOverlapXLSX(); // TODO : temporarily disabled.
+ void testTextBreakXLSX();
void testNumberFormatsXLSX();
void testTransparentBackground(OUString const & filename);
@@ -152,6 +153,7 @@ public:
CPPUNIT_TEST(testChartHatchFillXLSX);
CPPUNIT_TEST(testAxisTextRotationXLSX);
// CPPUNIT_TEST(testTextCanOverlapXLSX); // TODO : temporarily disabled.
+ CPPUNIT_TEST(testTextBreakXLSX);
CPPUNIT_TEST(testNumberFormatsXLSX);
CPPUNIT_TEST(testAutoTitleDelDefaultValue2007XLSX);
CPPUNIT_TEST(testAutoTitleDelDefaultValue2013XLSX);
@@ -985,6 +987,25 @@ void Chart2ImportTest::testTextCanOverlapXLSX()
}
*/
+void Chart2ImportTest::testTextBreakXLSX()
+{
+ // tdf#122091: To check textbreak value is true in case of 0° degree of Axis label rotation.
+ load("/chart2/qa/extras/data/xlsx/", "chart_label_text_break.xlsx");
+ uno::Reference< chart::XDiagram > mxDiagram;
+ uno::Reference< beans::XPropertySet > xAxisProp;
+ bool textBreak = false;
+ uno::Reference< chart::XChartDocument > xChartDoc ( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xChartDoc.is());
+ 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") >>= textBreak;
+ // Expected value of 'TextBreak' is true
+ CPPUNIT_ASSERT(textBreak);
+}
+
void Chart2ImportTest::testNumberFormatsXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "number-formats.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/chart_label_text_break.xlsx b/chart2/qa/extras/data/xlsx/chart_label_text_break.xlsx
new file mode 100755
index 000000000000..81c4958604d5
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/chart_label_text_break.xlsx
Binary files differ
diff --git a/oox/inc/drawingml/chart/objectformatter.hxx b/oox/inc/drawingml/chart/objectformatter.hxx
index 446c3d899293..8282844b1ab3 100644
--- a/oox/inc/drawingml/chart/objectformatter.hxx
+++ b/oox/inc/drawingml/chart/objectformatter.hxx
@@ -144,6 +144,11 @@ 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 7bcba408ffbb..f35cd5333e70 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -260,8 +260,8 @@ void AxisConverter::convertFromModel(
{
// do not overlap text unless all labels are visible
aAxisProp.setProperty( PROP_TextOverlap, mrModel.mnTickLabelSkip == 1 );
- // do not break text into several lines
- aAxisProp.setProperty( PROP_TextBreak, false );
+ // do not break text into several lines unless the rotation is 0 degree
+ aAxisProp.setProperty( PROP_TextBreak, ObjectFormatter::getTextRotation( mrModel.mxTextProp ) );
// 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 184cb111f02f..5b576d824ba3 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -1121,6 +1121,26 @@ 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 false;
+ }
+}
+
} // namespace chart
} // namespace drawingml
} // namespace oox