chart2/qa/extras/chart2import.cxx | 73 ++++++++++ chart2/qa/extras/data/xlsx/axis_title_default_rotation.xlsx |binary chart2/qa/extras/data/xlsx/axis_title_rotated.xlsx |binary chart2/qa/extras/data/xlsx/secondary_axis_title_default_rotation.xlsx |binary oox/inc/drawingml/chart/objectformatter.hxx | 8 - oox/inc/drawingml/chart/titlemodel.hxx | 3 oox/source/drawingml/chart/axiscontext.cxx | 12 + oox/source/drawingml/chart/objectformatter.cxx | 4 oox/source/drawingml/chart/titleconverter.cxx | 2 oox/source/drawingml/chart/titlemodel.cxx | 5 10 files changed, 90 insertions(+), 17 deletions(-)
New commits: commit bc4f6677a0d307fb19ad4fdfb627c80e59fd6835 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri May 8 14:53:04 2015 +0200 add test for xlsx rotated axis title import Change-Id: Ibfcf7cffe661efc1ce2063e87d38c45d943df69d diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index e20a5c2..7082077 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -87,6 +87,7 @@ public: void testAxisTitleDefaultRotationXLSX(); void testSecondaryAxisTitleDefaultRotationXLSX(); + void testAxisTitleRotationXLSX(); CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); @@ -135,6 +136,7 @@ public: CPPUNIT_TEST(testMinorTickMarksDefaultValue2013XLSX); CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX); CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX); + CPPUNIT_TEST(testAxisTitleRotationXLSX); CPPUNIT_TEST_SUITE_END(); private: @@ -1061,6 +1063,38 @@ void Chart2ImportTest::testSecondaryAxisTitleDefaultRotationXLSX() CPPUNIT_ASSERT_EQUAL(90.0, nRotation); } +void Chart2ImportTest::testAxisTitleRotationXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "axis_title_rotated.xlsx"); + Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + { + Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0); + CPPUNIT_ASSERT(xYAxis.is()); + Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW); + Reference<chart2::XTitle> xTitle = xTitled->getTitleObject(); + CPPUNIT_ASSERT(xTitle.is()); + Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("TextRotation"); + double nRotation = 0; + CPPUNIT_ASSERT(aAny >>= nRotation); + CPPUNIT_ASSERT_EQUAL(340.0, nRotation); + } + { + Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 1); + CPPUNIT_ASSERT(xYAxis.is()); + Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW); + Reference<chart2::XTitle> xTitle = xTitled->getTitleObject(); + CPPUNIT_ASSERT(xTitle.is()); + Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("TextRotation"); + double nRotation = 0; + CPPUNIT_ASSERT(aAny >>= nRotation); + CPPUNIT_ASSERT_EQUAL(270.0, nRotation); + } + +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/axis_title_rotated.xlsx b/chart2/qa/extras/data/xlsx/axis_title_rotated.xlsx new file mode 100644 index 0000000..29e42d8 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/axis_title_rotated.xlsx differ commit 13ede60a9604564339647cff6193d9343ea2fd48 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri May 8 14:52:14 2015 +0200 also add test for secondary axis, related tdf#75316 Change-Id: I88f46f7724296e1c58cf7604a0c514de91b5ae2a diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index a25449e..e20a5c2 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -86,6 +86,7 @@ public: void testMinorTickMarksDefaultValue2013XLSX(); void testAxisTitleDefaultRotationXLSX(); + void testSecondaryAxisTitleDefaultRotationXLSX(); CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); @@ -133,6 +134,7 @@ public: CPPUNIT_TEST(testMajorTickMarksDefaultValue2013XLSX); CPPUNIT_TEST(testMinorTickMarksDefaultValue2013XLSX); CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX); + CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX); CPPUNIT_TEST_SUITE_END(); private: @@ -1042,6 +1044,23 @@ void Chart2ImportTest::testAxisTitleDefaultRotationXLSX() CPPUNIT_ASSERT_EQUAL(90.0, nRotation); } +void Chart2ImportTest::testSecondaryAxisTitleDefaultRotationXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "secondary_axis_title_default_rotation.xlsx"); + Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 1); + CPPUNIT_ASSERT(xYAxis.is()); + Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW); + Reference<chart2::XTitle> xTitle = xTitled->getTitleObject(); + CPPUNIT_ASSERT(xTitle.is()); + Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("TextRotation"); + double nRotation = 0; + CPPUNIT_ASSERT(aAny >>= nRotation); + CPPUNIT_ASSERT_EQUAL(90.0, nRotation); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/secondary_axis_title_default_rotation.xlsx b/chart2/qa/extras/data/xlsx/secondary_axis_title_default_rotation.xlsx new file mode 100644 index 0000000..de5d039 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/secondary_axis_title_default_rotation.xlsx differ commit 5d69cd2eabb39c9a1be6d641f3bc901c84ea3608 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri May 8 14:39:30 2015 +0200 add test for tdf#75316 Change-Id: Ic9f20c90e54f53484d67c1c38530dbac9638cbfe diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index f7c7799..a25449e 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -85,6 +85,8 @@ public: void testMajorTickMarksDefaultValue2013XLSX(); void testMinorTickMarksDefaultValue2013XLSX(); + void testAxisTitleDefaultRotationXLSX(); + CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); CPPUNIT_TEST(testSteppedLines); @@ -130,6 +132,7 @@ public: CPPUNIT_TEST(testRAngAxDefaultValue2013XLSX); CPPUNIT_TEST(testMajorTickMarksDefaultValue2013XLSX); CPPUNIT_TEST(testMinorTickMarksDefaultValue2013XLSX); + CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX); CPPUNIT_TEST_SUITE_END(); private: @@ -1022,6 +1025,23 @@ void Chart2ImportTest::testMinorTickMarksDefaultValue2013XLSX() CPPUNIT_ASSERT_EQUAL(chart2::TickmarkStyle::INNER | chart2::TickmarkStyle::OUTER, nMajorTickmarks); } +void Chart2ImportTest::testAxisTitleDefaultRotationXLSX() +{ + load("/chart2/qa/extras/data/xlsx/", "axis_title_default_rotation.xlsx"); + Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0); + CPPUNIT_ASSERT(xYAxis.is()); + Reference<chart2::XTitled> xTitled(xYAxis, uno::UNO_QUERY_THROW); + Reference<chart2::XTitle> xTitle = xTitled->getTitleObject(); + CPPUNIT_ASSERT(xTitle.is()); + Reference<beans::XPropertySet> xPropSet(xTitle, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("TextRotation"); + double nRotation = 0; + CPPUNIT_ASSERT(aAny >>= nRotation); + CPPUNIT_ASSERT_EQUAL(90.0, nRotation); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/axis_title_default_rotation.xlsx b/chart2/qa/extras/data/xlsx/axis_title_default_rotation.xlsx new file mode 100644 index 0000000..5cda3af Binary files /dev/null and b/chart2/qa/extras/data/xlsx/axis_title_default_rotation.xlsx differ commit 28ca767e57e00990428b804154bf15b940c63bd1 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Fri May 8 14:22:01 2015 +0200 default text rotation for secondary axis is also from parent, tdf#75316 Change-Id: I0d17787e1b554854853910b1196582985864c944 diff --git a/oox/source/drawingml/chart/axiscontext.cxx b/oox/source/drawingml/chart/axiscontext.cxx index 058f759..e735ac8 100644 --- a/oox/source/drawingml/chart/axiscontext.cxx +++ b/oox/source/drawingml/chart/axiscontext.cxx @@ -135,7 +135,7 @@ ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const At return 0; case C_TOKEN( title ): { - bool bVerticalDefault = mrModel.mnAxisPos == XML_l; + bool bVerticalDefault = mrModel.mnAxisPos == XML_l || mrModel.mnAxisPos == XML_r; sal_Int32 nDefaultRotation = bVerticalDefault ? -5400000 : 0; return new TitleContext( *this, mrModel.mxTitle.create(nDefaultRotation) ); } commit 07e3155a666e85b8213608423ae84dbd2b30c3dc Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Wed May 6 06:08:47 2015 +0200 inherit default title rotation from parent, tdf#75316 Change-Id: I2cf609a3f2c5eb1f9d7716b3ee89d4131d942ffb diff --git a/oox/inc/drawingml/chart/objectformatter.hxx b/oox/inc/drawingml/chart/objectformatter.hxx index 1e8d780..c84afc6 100644 --- a/oox/inc/drawingml/chart/objectformatter.hxx +++ b/oox/inc/drawingml/chart/objectformatter.hxx @@ -34,8 +34,6 @@ namespace oox { namespace drawingml { namespace chart { - - /** Enumerates different object types for specific automatic formatting behaviour. */ enum ObjectType { @@ -67,8 +65,6 @@ enum ObjectType OBJECTTYPE_DATATABLE /// Data table. }; - - struct ChartSpaceModel; struct ObjectFormatterData; struct PictureOptionsModel; @@ -125,7 +121,7 @@ public: static void convertTextRotation( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, - bool bSupportsStacked ); + bool bSupportsStacked, sal_Int32 nDefaultRotation = 0); /** Sets number format properties to the passed property set. */ void convertNumberFormat( @@ -147,8 +143,6 @@ private: std::shared_ptr< ObjectFormatterData > mxData; }; - - } // namespace chart } // namespace drawingml } // namespace oox diff --git a/oox/inc/drawingml/chart/titlemodel.hxx b/oox/inc/drawingml/chart/titlemodel.hxx index dad4914..9e09c44 100644 --- a/oox/inc/drawingml/chart/titlemodel.hxx +++ b/oox/inc/drawingml/chart/titlemodel.hxx @@ -51,8 +51,9 @@ struct TitleModel LayoutRef mxLayout; /// Layout/position of the frame. TextRef mxText; /// Text source of the title. bool mbOverlay; /// True = title may overlay other objects. + sal_Int32 mnDefaultRotation; - explicit TitleModel(); + explicit TitleModel(sal_Int32 nDefaultRotation = 0); ~TitleModel(); }; diff --git a/oox/source/drawingml/chart/axiscontext.cxx b/oox/source/drawingml/chart/axiscontext.cxx index 618e3e8..058f759 100644 --- a/oox/source/drawingml/chart/axiscontext.cxx +++ b/oox/source/drawingml/chart/axiscontext.cxx @@ -115,6 +115,9 @@ ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const At case C_TOKEN( majorTickMark ): mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_out : XML_cross ); return 0; + case C_TOKEN(axPos): + mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID ); + return 0; case C_TOKEN( minorGridlines ): return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() ); case C_TOKEN( minorTickMark ): @@ -131,7 +134,11 @@ ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const At mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo ); return 0; case C_TOKEN( title ): - return new TitleContext( *this, mrModel.mxTitle.create() ); + { + bool bVerticalDefault = mrModel.mnAxisPos == XML_l; + sal_Int32 nDefaultRotation = bVerticalDefault ? -5400000 : 0; + return new TitleContext( *this, mrModel.mxTitle.create(nDefaultRotation) ); + } case C_TOKEN( txPr ): return new TextBodyContext( *this, mrModel.mxTextProp.create() ); } @@ -175,9 +182,6 @@ ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const Att case C_TOKEN( auto ): mrModel.mbAuto = rAttribs.getBool( XML_val, !bMSO2007Doc ); return 0; - case C_TOKEN( axPos ): - mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID ); - return 0; case C_TOKEN( lblAlgn ): mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr ); return 0; diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index b61b991..fae8249 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -1067,7 +1067,7 @@ void ObjectFormatter::convertTextFormatting( PropertySet& rPropSet, const TextCh pFormat->convertTextFormatting( rPropSet, rTextProps ); } -void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, bool bSupportsStacked ) +void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, bool bSupportsStacked, sal_Int32 nDefaultRotation ) { if( rxTextProp.is() ) { @@ -1081,7 +1081,7 @@ void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef /* Chart2 expects rotation angle as double value in range of [0,360). OOXML counts clockwise, Chart2 counts counterclockwise. */ - double fAngle = static_cast< double >( bStacked ? 0 : rxTextProp->getTextProperties().moRotation.get( 0 ) ); + double fAngle = static_cast< double >( bStacked ? 0 : rxTextProp->getTextProperties().moRotation.get( nDefaultRotation ) ); // MS Office UI allows values only in range of [-90,90]. if ( fAngle < -5400000.0 || fAngle > 5400000.0 ) { diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx index 34cc4d7..743fe1f 100644 --- a/oox/source/drawingml/chart/titleconverter.cxx +++ b/oox/source/drawingml/chart/titleconverter.cxx @@ -162,7 +162,7 @@ void TitleConverter::convertFromModel( const Reference< XTitled >& rxTitled, con // frame rotation OSL_ENSURE( !mrModel.mxTextProp || !rText.mxTextBody, "TitleConverter::convertFromModel - multiple text properties" ); ModelRef< TextBody > xTextProp = mrModel.mxTextProp.is() ? mrModel.mxTextProp : rText.mxTextBody; - ObjectFormatter::convertTextRotation( aPropSet, xTextProp, true ); + ObjectFormatter::convertTextRotation( aPropSet, xTextProp, true, mrModel.mnDefaultRotation ); // register the title and layout data for conversion of position registerTitleLayout( xTitle, mrModel.mxLayout, eObjType, nMainIdx, nSubIdx ); diff --git a/oox/source/drawingml/chart/titlemodel.cxx b/oox/source/drawingml/chart/titlemodel.cxx index 1f71533..c9c8eec 100644 --- a/oox/source/drawingml/chart/titlemodel.cxx +++ b/oox/source/drawingml/chart/titlemodel.cxx @@ -32,8 +32,9 @@ TextModel::~TextModel() { } -TitleModel::TitleModel() : - mbOverlay( false ) +TitleModel::TitleModel(sal_Int32 nDefaultRotation) : + mbOverlay( false ), + mnDefaultRotation(nDefaultRotation) { } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits