Kaydet (Commit) 015569fc authored tarafından Balazs Varga's avatar Balazs Varga Kaydeden (comit) Bartosz Kosiorek

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: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst 7fc28192
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
void testChartHatchFillXLSX(); void testChartHatchFillXLSX();
void testAxisTextRotationXLSX(); void testAxisTextRotationXLSX();
// void testTextCanOverlapXLSX(); // TODO : temporarily disabled. // void testTextCanOverlapXLSX(); // TODO : temporarily disabled.
void testTextBreakXLSX();
void testNumberFormatsXLSX(); void testNumberFormatsXLSX();
void testTransparentBackground(OUString const & filename); void testTransparentBackground(OUString const & filename);
...@@ -158,6 +159,7 @@ public: ...@@ -158,6 +159,7 @@ public:
CPPUNIT_TEST(testChartHatchFillXLSX); CPPUNIT_TEST(testChartHatchFillXLSX);
CPPUNIT_TEST(testAxisTextRotationXLSX); CPPUNIT_TEST(testAxisTextRotationXLSX);
// CPPUNIT_TEST(testTextCanOverlapXLSX); // TODO : temporarily disabled. // CPPUNIT_TEST(testTextCanOverlapXLSX); // TODO : temporarily disabled.
CPPUNIT_TEST(testTextBreakXLSX);
CPPUNIT_TEST(testNumberFormatsXLSX); CPPUNIT_TEST(testNumberFormatsXLSX);
CPPUNIT_TEST(testAutoTitleDelDefaultValue2007XLSX); CPPUNIT_TEST(testAutoTitleDelDefaultValue2007XLSX);
CPPUNIT_TEST(testAutoTitleDelDefaultValue2013XLSX); CPPUNIT_TEST(testAutoTitleDelDefaultValue2013XLSX);
...@@ -1013,6 +1015,25 @@ void Chart2ImportTest::testTextCanOverlapXLSX() ...@@ -1013,6 +1015,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() void Chart2ImportTest::testNumberFormatsXLSX()
{ {
load("/chart2/qa/extras/data/xlsx/", "number-formats.xlsx"); load("/chart2/qa/extras/data/xlsx/", "number-formats.xlsx");
......
...@@ -144,6 +144,11 @@ public: ...@@ -144,6 +144,11 @@ public:
/** Returns true, if the passed shape properties have automatic fill mode. */ /** Returns true, if the passed shape properties have automatic fill mode. */
static bool isAutomaticFill( const ModelRef< Shape >& rxShapeProp ); 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: private:
std::shared_ptr< ObjectFormatterData > mxData; std::shared_ptr< ObjectFormatterData > mxData;
}; };
......
...@@ -260,8 +260,8 @@ void AxisConverter::convertFromModel( ...@@ -260,8 +260,8 @@ void AxisConverter::convertFromModel(
{ {
// do not overlap text unless all labels are visible // do not overlap text unless all labels are visible
aAxisProp.setProperty( PROP_TextOverlap, mrModel.mnTickLabelSkip == 1 ); aAxisProp.setProperty( PROP_TextOverlap, mrModel.mnTickLabelSkip == 1 );
// do not break text into several lines // do not break text into several lines unless the rotation is 0 degree
aAxisProp.setProperty( PROP_TextBreak, false ); aAxisProp.setProperty( PROP_TextBreak, ObjectFormatter::getTextRotation( mrModel.mxTextProp ) );
// do not stagger labels in two lines // do not stagger labels in two lines
aAxisProp.setProperty( PROP_ArrangeOrder, cssc::ChartAxisArrangeOrderType_SIDE_BY_SIDE ); aAxisProp.setProperty( PROP_ArrangeOrder, cssc::ChartAxisArrangeOrderType_SIDE_BY_SIDE );
//! TODO #i58731# show n-th category //! TODO #i58731# show n-th category
......
...@@ -1121,6 +1121,26 @@ bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp ) ...@@ -1121,6 +1121,26 @@ bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp )
return !rxShapeProp || !rxShapeProp->getFillProperties().moFillType.has(); 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 chart
} // namespace drawingml } // namespace drawingml
} // namespace oox } // namespace oox
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment