oox/source/drawingml/table/tablecell.cxx | 42 +++++++++++++++++++++ sd/qa/unit/data/pptx/tableBorderLineStyle.pptx |binary sd/qa/unit/import-tests.cxx | 48 +++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-)
New commits: commit f9c8651506adddad4941fe08e9e76a78d14a9fe0 Author: Matus Uzak <[email protected]> Date: Wed Apr 13 02:00:03 2016 +0200 tdf#90736: PPTX import: Improved table border line style support Map preset line dash values from ooxml to the smaller set of LO's predefined table border line styles. Map custom dashing scheme to a simple dashed line style. Change-Id: Ia81d94cb7e20b05f1c2cc0c20c8ad398c5613d6c Reviewed-on: https://gerrit.libreoffice.org/24048 Tested-by: Jenkins <[email protected]> Reviewed-by: Katarina Behrens <[email protected]> diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 4df26bb..9a56950 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/table/XTable.hpp> #include <com/sun/star/table/XMergeableCellRange.hpp> +#include <com/sun/star/table/BorderLineStyle.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> @@ -72,7 +73,7 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, sal_Int32 nPropId ) { BorderLine2 aBorderLine; - if( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill )) + if ( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill )) { Color aColor = rLineProperties.maLineFill.getBestSolidColor(); aBorderLine.Color = aColor.getColor( rFilterBase.getGraphicHelper() ); @@ -91,6 +92,45 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, aBorderLine.LineDistance = 0; } + if ( rLineProperties.moPresetDash.has() ) + { + switch ( rLineProperties.moPresetDash.get() ) + { + case XML_dot: + case XML_sysDot: + aBorderLine.LineStyle = ::table::BorderLineStyle::DOTTED; + break; + case XML_dash: + case XML_lgDash: + case XML_sysDash: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED; + break; + case XML_dashDot: + case XML_lgDashDot: + case XML_sysDashDot: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT; + break; + case XML_lgDashDotDot: + case XML_sysDashDotDot: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT_DOT; + break; + case XML_solid: + aBorderLine.LineStyle = ::table::BorderLineStyle::SOLID; + break; + default: + aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED; + break; + } + } + else if ( !rLineProperties.maCustomDash.empty() ) + { + aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED; + } + else + { + aBorderLine.LineStyle = ::table::BorderLineStyle::NONE; + } + PropertySet aPropSet( rxPropSet ); aPropSet.setProperty( nPropId, aBorderLine ); } diff --git a/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx b/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx new file mode 100644 index 0000000..c46b7bc Binary files /dev/null and b/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index da4d4c4..a9b7f0d 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -56,6 +56,7 @@ #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> #include <com/sun/star/chart2/data/XDataSequence.hpp> #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> +#include <com/sun/star/table/BorderLineStyle.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> @@ -97,6 +98,7 @@ public: void testBnc584721_4(); void testBnc904423(); void testShapeLineStyle(); + void testTableBorderLineStyle(); void testBnc862510_6(); void testBnc862510_7(); #if ENABLE_PDFIMPORT @@ -143,6 +145,7 @@ public: CPPUNIT_TEST(testBnc584721_4); CPPUNIT_TEST(testBnc904423); CPPUNIT_TEST(testShapeLineStyle); + CPPUNIT_TEST(testTableBorderLineStyle); CPPUNIT_TEST(testBnc862510_6); CPPUNIT_TEST(testBnc862510_7); #if ENABLE_PDFIMPORT @@ -1024,6 +1027,51 @@ void SdImportTest::testShapeLineStyle() xDocShRef->DoClose(); } +void SdImportTest::testTableBorderLineStyle() +{ + sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx"), PPTX ); + + // TODO: If you are working on improvement of table border line style + // support, then expect this unit test to fail. + + const sal_Int16 nObjBorderLineStyles[] = + { + ::table::BorderLineStyle::DASHED, + ::table::BorderLineStyle::DASH_DOT_DOT, + ::table::BorderLineStyle::DASH_DOT, + ::table::BorderLineStyle::DOTTED, + ::table::BorderLineStyle::DASHED, + ::table::BorderLineStyle::DOTTED, + ::table::BorderLineStyle::DASHED, + ::table::BorderLineStyle::DASH_DOT, + ::table::BorderLineStyle::DASH_DOT, + ::table::BorderLineStyle::SOLID, + ::table::BorderLineStyle::NONE + }; + + const SdrPage *pPage = GetPage( 1, xDocShRef ); + CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(nObjBorderLineStyles), pPage->GetObjCount()); + + sdr::table::SdrTableObj *pTableObj; + uno::Reference< table::XCellRange > xTable; + uno::Reference< beans::XPropertySet > xCell; + table::BorderLine2 aBorderLine; + + for (size_t i = 0; i < SAL_N_ELEMENTS(nObjBorderLineStyles); i++) + { + pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(i)); + CPPUNIT_ASSERT( pTableObj ); + xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW); + xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); + xCell->getPropertyValue("TopBorder") >>= aBorderLine; + if (aBorderLine.LineWidth > 0) { + CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles[i], aBorderLine.LineStyle); + } + } + + xDocShRef->DoClose(); +} + void SdImportTest::testBnc862510_6() { // Black text was imported instead of gray _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
